pastebin - collaborative debugging tool
kpaste.net RSS


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)

  1. <?php
  2. $handle = fopen("postcodes.txt", "r");
  3. if ($handle) {
  4.     while (($postcode = fgets($handle)) !== false) {
  5.         $postcode = trim($postcode);
  6.         if (empty($postcode)) continue;
  7.                 $ch = curl_init();
  8.                 $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";
  9.                 curl_setopt($ch, CURLOPT_URL, $url);
  10.                 curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
  11.                 $result = curl_exec($ch);
  12.                 curl_close ($ch);
  13.                
  14.                 $dom = new DOMDocument();
  15.                 @$dom->loadHTML($result);
  16.                 $finder = new DomXPath($dom);
  17.                 $nodes = $finder->query("//option");
  18.                
  19.                 foreach ($nodes as $node) {
  20.                         if ($node->nodeValue == "Please select your address from the list below.") continue;
  21.                 $address = preg_split("/, /", $node->nodeValue);
  22.                 $firstline = $address[0];
  23.                 if (preg_match("/^\d+.*/", $firstline)) {
  24.                         preg_match("/^\d+/", $firstline, $number);
  25.                                 echo "$number[0], $postcode\r\n";
  26.                                 unset($number);
  27.                         } else {
  28.                                 $number = 0;
  29.                                 $names[] = $firstline;
  30.                                 if (preg_match("/^\d+.*/", $address[1])) preg_match("/^\d+/", $address[1], $number);
  31.                                 echo "$firstline, $number[0], $postcode\r\n";
  32.                                 unset($number);
  33.                         }
  34.         }
  35.         }
  36. }
  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