pastebin - collaborative debugging tool
kpaste.net RSS

Difference between
modified post 108c by Anonymous on Sun 13th Apr 2014 05:57
original post f4b52687a by Anonymous on Sun 13th Apr 2014 05:23
Download diff
Show old version | new version | both versions

    
11
<?php
22
$handle = fopen("postcodes.txt", "r");
33
if ($handle) {
44
    while (($postcode = fgets($handle)) !== false) {
55
    	$postcode = trim($postcode);
66
    	if (empty($postcode)) continue;
77
		$ch = curl_init();
88
		$url = "http://www.dslchecker.bt.com/pls/adsl/ADSLChecker.AddressOutput?URL=&SP_NAME=a%20service%20provider&postcode=$postcode&VERSION=29&MS=E&CAP=yes&AEA=N";
99
		curl_setopt($ch, CURLOPT_URL, $url);
1010
		curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
1111
		$result = curl_exec($ch);
1212
		curl_close ($ch);
1313
1414
		$dom = new DOMDocument();
1515
		@$dom->loadHTML($result);
1616
		$finder = new DomXPath($dom);
1717
		$nodes = $finder->query("//option");
1818
1919
		foreach ($nodes as $node) {
20-
    		echo $node->nodeValue."\r\n";
20+
			if ($node->nodeValue == "Please select your address from the list below.") continue;
21-
    	}
21+
    		$address = preg_split("/, /", $node->nodeValue);
22-
	}
22+
    		$firstline = $address[0];
23-
}
23+
    		if (preg_match("/^\d+.*/", $firstline)) {
24-
24+
    			preg_match("/^\d+/", $firstline, $number);
25-
?>
25+
				echo "$number[0], $postcode\r\n";
26-
26+
				unset($number);
27-
27+
			} else {
28-
28+
				$number = 0;
29-
29+
				$names[] = $firstline;
30-
30+
				if (preg_match("/^\d+.*/", $address[1])) preg_match("/^\d+/", $address[1], $number);
31-
31+
				echo "$firstline, $number[0], $postcode\r\n";
32-
32+
				unset($number);
33-
33+
			}
34-
34+
    	}
35-
35+
	}
36-
36+
}
37-
37+
?>

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with {%HIGHLIGHT}




All content is user-submitted.
The administrators of this site (kpaste.net) are not responsible for their content.
Abuse reports should be emailed to us at