Ricardo123 Posted June 14, 2015 Share Posted June 14, 2015 Example of it would be here: website: http://bit.ly/1C0IfkY Selected Source I only want to get <p data-iceapc="3" data-iceapw="6"><span data-iceapw="2" style="font-size:25px; color:#98293D;">11am: 2-0-7 </span> <span data-iceapw="2" style="font-size:25px; color:#98293D;">4pm: 7-2-3 </span> <span data-iceapw="2" style="font-size:25px; color:#98293D;">9pm: __ </span></p> Here's my code $dom = new DOMDocument(); $dom->loadHTML($Url); $xpath = new DomXPath($dom); $nodes = $xpath->query('//span[@style="font-size:25px; color:#98293D"]'); foreach ($nodes as $node) { echo $node->nodeValue; } Quote Link to comment Share on other sites More sharing options...
Destramic Posted June 14, 2015 Share Posted June 14, 2015 use the code below of top of your script's while developing...let us know if you get an error of some kind. ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(E_ALL); Quote Link to comment Share on other sites More sharing options...
Ricardo123 Posted June 14, 2015 Author Share Posted June 14, 2015 Code added but still not working got the same result. Please help me figure out how to solve this problem or can you you suggest me something that can get what I want to get from the site Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted June 14, 2015 Share Posted June 14, 2015 (edited) loadHTML expects the HTML contents, not a url to a webpage. You need to first get the contents of the webpage (using file_get_contents) and then pass that to loadHTML $HTML = file_get_contents($Url); // get the html contents of the webpage $dom->loadHTML($HTML); // pass the webpage contents to loadHTML I managed to get the values of the three span element using this path query $nodes = $xpath->query('//span[@style="font-size:25px; color:#98293D;"]'); Edited June 14, 2015 by Ch0cu3r Quote Link to comment Share on other sites More sharing options...
Ricardo123 Posted June 14, 2015 Author Share Posted June 14, 2015 Heres the updated code <?php ini_set('display_startup_errors', 1); ini_set('display_errors', 1); error_reporting(E_ALL); $html = file_get_contents("http://www.philippinepcsolotto.com/results/swertres-results"); $dom = new DOMDocument(); $dom->loadHTML($html); $xpath = new DomXPath($dom); $nodes = $xpath->query('//span[@style="font-size:25px; color:#98293D"]'); foreach ($nodes as $node) { echo $node->nodeValue; } ?> Now after adding new code and revising it errors pops out here is it PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Namespace prefix xmlns of attribute fb is not defined in Entity, line: 3 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Tag header invalid in Entity, line: 182 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Tag nav invalid in Entity, line: 195 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : p in Entity, line: 222 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Tag article invalid in Entity, line: 224 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Tag header invalid in Entity, line: 225 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : a in Entity, line: 233 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Tag aside invalid in Entity, line: 316 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Opening and ending tag mismatch: div and center in Entity, line: 496 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Tag footer invalid in Entity, line: 503 in /home/a8880105/public_html/try.php on line 12 PHP Error Message Warning: DOMDocument::loadHTML() [domdocument.loadhtml]: Unexpected end tag : a in Entity, line: 716 in /home/a8880105/public_html/try.php on line 12 Help anyone. Quote Link to comment Share on other sites More sharing options...
Ch0cu3r Posted June 14, 2015 Share Posted June 14, 2015 Add libxml_use_internal_errors (true); Before the use of loadHTML Also you need to add the semi-colon after color:#98293D otherwise it will not find the span tag. $nodes = $xpath->query('//span[@style="font-size:25px; color:#98293D;"]'); // semi-colon added after color:#98293D Quote Link to comment Share on other sites More sharing options...
Ricardo123 Posted June 15, 2015 Author Share Posted June 15, 2015 Thank you guys the script is now runnig. I love how fast these guys and members response to questions about php Thank you so much. I try using before libxml function(true) then after loadhtml libxml (false) which didnt work so I try these and its a magic it works. Quote Link to comment 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.