I'm trying to get baseball scores each day and use it in a script to show on my site. Anyone familiar with web scraping and can point me to some sample php scripts on doing scraping? I don't want rss. Thanks.
coopster
2:26 am on Mar 26, 2014 (gmt 0)
Welcome to WebmasterWorld, bayridge.
You can build your own spider/bot using PHP and the cURL API. The PHP manual pages have some examples:
There's a really nice step by step tutorial for DIY scraping programming here: [oooff.com...]
bayridge
3:01 pm on Apr 5, 2014 (gmt 0)
Thanks for your help. I will give it a try.
bayridge
4:37 pm on Apr 5, 2014 (gmt 0)
Not working for me. Tried it and get errors.
Warning: file_get_contents() [function.file-get-contents]: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/content/m/i/k/mikey/html/mysite/scrape01.php on line 4
Warning: file_get_contents(http://www.example.com) [function.file-get-contents]: failed to open stream: php_network_getaddresses: getaddrinfo failed: Name or service not known in /home/content/m/i/k/mikey/html/mysite/scrape01.php on line 4
Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Empty string supplied as input in /home/content/m/i/k/mikey/html/mysite/scrape01.php on line 5
Used your script <?php $doc = new DOMDocument(); libxml_use_internal_errors(true); $html=file_get_contents("http://www.example.com"); $doc->loadHTML( $html); ?>
bayridge
4:40 pm on Apr 5, 2014 (gmt 0)
First example worked ok from pokemon site.
Second one didn't work
Parse error: syntax error, unexpected T_VARIABLE in /home/content/m/i/k/mikey/html/mysite/scrape02.php on line 2