0

I'm using the following code to scrape a table:

header('Content-Type: text/html; charset=utf-8'); 

$curl = curl_init('http://www.nhs.uk/service-search/GP/m410ux/Results/4/-2.35167407989502/53.4519462585449/4/0?distance=25');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
$page = curl_exec($curl);
if(curl_errno($curl)) // check for execution errors { 
    echo 'Scraper error: ' . curl_error($curl);
    exit; 
}
curl_close($curl);

$regex = '/<table border="1" cellspacing="0" class="items-7" summary="GP    details for the ones you have selected">(.*?)<\/table>/s';
if ( preg_match($regex, $page, $list) )
    echo $list[0];
else 

which outputs the following: http://mt-cloud.co.uk/scrape/

How do I then get each column of the table inserted into a mysql table?

Kindest regards Max

jean-max
  • 1,640
  • 1
  • 18
  • 33
itguyme
  • 43
  • 2
  • 11
  • http://stackoverflow.com/questions/8816194/how-to-parse-html-table-using-php – yivi Jan 03 '17 at 10:53
  • Possible duplicate of [How do you parse and process HTML/XML in PHP?](http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) – tambre Jan 03 '17 at 10:58
  • With the links provided am I meant to scrape it into XML format instead? i'm confused. – itguyme Jan 03 '17 at 11:00
  • Links provided give a full answer to your problem. Check how it done there, and you are set to go. Scraping HTML and XML is almost the same thing. – yivi Jan 03 '17 at 11:05

0 Answers0