Hey guys, Im not exactly new to screen scraping in php, however im becoming really stuck on this. What im trying to do is grab specific data from an external webpage an print it on my own webpage. So far all i have achieved is displaying the entire external webpage on my page. Basically im not sure how to display only what i want from that external page. I have looked into cURL but still completely stuck. Any help or advice would be much appreciated, thanks!
I've never been a fan of scraping with PHP. In my opinion Perl is a much better suited tool for the job. If you are open to Perl I would look in to LWP::UserAgent, WWW::Mechanize, and visit CPAN for crawler/scraper modules. If you must use PHP and cURL and you are already able to fetch the HTML content your next step is to parse the file and "grab" what you need. Regular expressions should make the job easy. Look at the HTML source and try to spot similarities in tags/content around the data you are looking to parse.
Thanks a lot for answering BUT, I have found a simple php code as another option to trial. Maybe I should be a little more specific with my question first - I'm trying to display the data directly beneath 'In circulation' from this url: torn.com/iteminfo.php?XID=337 Exactly how can i go about using the code above for this, or is there an easier way? Thanks
The following prints 16 $matches = array(); preg_match('/ <td style="text\-align\:center\;">(.*)<\/td>(.*)/', $page_contents, $matches); echo $matches[1]; Code (markup):