PDA

View Full Version : Fetching data from webpage based on elements ID/Class



AlexM7315
17 Apr 2011, 08:23 AM
Hi, I'm searching for a way or an existing API/function that does the following:

I want to give this function a URL and an ID/Class,
the function will return an array of the HTML/Text content of
the HTML elements that possess these attributes.

Where do I even start with this thing?

is_numeric
18 Apr 2011, 11:33 AM
look at cURL in PHP

example...



$url = "www.mysite.com"; // change to suit
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$html = curl_exec($ch);
curl_close($ch);
echo $html; // $html contains the page, in HTML, which you have scraped


You will need to process the $html variable to fish out what you want and output it to the page.