Jump to content

qiqakotyi

New Members
  • Posts

    1
  • Joined

  • Last visited

qiqakotyi's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. 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>"; ?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.