- <?php
- $handle = fopen("postcodes.txt", "r");
- if ($handle) {
- while (($postcode = fgets($handle)) !== false) {
- $postcode = trim($postcode);
- if (empty($postcode)) continue;
- $ch = curl_init();
- $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";
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
- $result = curl_exec($ch);
- curl_close ($ch);
- $dom = new DOMDocument();
- @$dom->loadHTML($result);
- $finder = new DomXPath($dom);
- $nodes = $finder->query("//option");
- foreach ($nodes as $node) {
- if ($node->nodeValue == "Please select your address from the list below.") continue;
- $address = preg_split("/, /", $node->nodeValue);
- $firstline = $address[0];
- if (preg_match("/^\d+.*/", $firstline)) {
- preg_match("/^\d+/", $firstline, $number);
- echo "$number[0], $postcode\r\n";
- unset($number);
- } else {
- $number = 0;
- $names[] = $firstline;
- if (preg_match("/^\d+.*/", $address[1])) preg_match("/^\d+/", $address[1], $number);
- echo "$firstline, $number[0], $postcode\r\n";
- unset($number);
- }
- }
- }
- }
- ?>
Untitled
Posted by Anonymous on Sun 13th Apr 2014 05:57
raw | new post
view followups (newest first): Untitled by Anonymous
modification of post by Anonymous (view diff)
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.
kpaste.net RSS