|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2018-05-11 15:13 UTC] kj-8791 at hotmail dot com
Description: ------------ problem is only $data is null in a local windows IIS even if i connect a domain to my localhost, so a question is Windows 10 Enterprise lacking something default as PHP stats XPath is integrated and is working in a linux enviroment?? i have PHP 7.2.5 plus Microsoft VC15 runtime no changes are made to the system files standard installation of PHP Question? What is needed for this to work in windows? as Windows Enterprise should have all needed because PHP code works Test script: --------------- //Get parsing url for retrieving forex data $parseurl="https://www.investing.com/technical/technical-summary"; //Create XPath object $parsedoc=new DOMDocument();@$parsedoc->loadHTMLFile($parseurl);$xpath=new DOMXPath($parsedoc); $data=$xpath->query('//*[@id="technical_summary_container"]/table/tbody/tr[3]/td[2]')->item(0)->nodeValue."\n"; echo $data; Expected result: ---------------- $data should have one of this results Strong Sell Sell Neutral Buy Strong Buy Actual result: -------------- $data is null in a windows 10 Enterprise PHP standard installation, without plugins and external packages PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 07:00:01 2025 UTC |
> added in index.php > libxml_use_internal_errors(true); shows forbidden so i added > ini_set('user_agent','Mozilla/4.0 (compatible; MSIE 6.0)'); and it works So this is not XPath related; actually, it is not even a bug in PHP. You always have to properly check the return values for failures. > useragent should be added as default in php.ini No. Instead you may think about *why* the site responds with 403 Forbidden, if no User-Agent is sent. Hint: likely the site owners don't want their site to be scraped by arbitrary bots.