qiqakotyi Posted September 6, 2013 Share Posted September 6, 2013 Hi all , I'm new to php. I'm trying to scrape the soccer website (http://www.soccerladuma.co.za/leagues/tables) the league tables on it , i have tried to get the element by it and tag name but i'm getting a blank screen.I only get the whole page if when i remove my tag name n tag id code. Please help , see code below that gets the page and plz lead me to how to get that specific league table from this site. <?php $url = "http://www.soccerladuma.co.za/leagues/tables"; // Create a stream so that we can set a User-Agent $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n" . "Cookie: foo=bar\r\n" . "User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US) AppleWebKit/534.13 (KHTML, like Gecko) Chrome/9.0.597.107 Safari/534.13\r\n" ) ); $context = stream_context_create($opts); $str = file_get_contents($url, false, $context); $str = strip_tags($str,"<style>"); $substring = substr($str,strpos($str,"<style"),strpos($str,"</style>")+2); $dom = new DOMDocument(); $dom ->loadHTML($str); //@ is puted to prevent html warnings $xpath = new DOMXPath($dom); echo "<pre>"; print_r($dom->textContent); echo "<pre>"; ? Quote Link to comment https://forums.phpfreaks.com/topic/281910-php-web-scraping/ Share on other sites More sharing options...
requinix Posted September 6, 2013 Share Posted September 6, 2013 Hi all , I'm new to php. I'm trying to scrape the soccer website (http://www.soccerladuma.co.za/leagues/tables) the league tables on it ,Stop. They specifically prohibit you from doing that: You acknowledge and agree that the material and content contained within the Website is made available for your personal non-commercial use only and that you may download such material and content onto only one computer hard drive for such purpose. Any other use of the material and content of the Website is strictly prohibited. You agree not to (and agree not to assist or facilitate any third party to) copy, reproduce, transmit, publish, display, distribute, commercially exploit or create derivative works of such material and content. Find another way or a different place to get the information you need. Quote Link to comment https://forums.phpfreaks.com/topic/281910-php-web-scraping/#findComment-1448420 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.