shelluk Posted January 8, 2013 Share Posted January 8, 2013 (edited) Hi I'm exploring the DOMDocument class for the first time to do some screen scraping. I am getting the following error though: PHP Warning: DOMDocument::loadHTMLFile(https://192.168.1.59/): failed to open stream: HTTP request failed! HTTP/1.1 505 HTTP Version not supported\r\n in /var/www/default/path/file.php on line 25 PHP Warning: DOMDocument::loadHTMLFile(): I/O warning : failed to load external entity "https%3A%2F%2F192.168.1.59%2F" in /var/www/default/path/file.php on line 25 I've tried adding urlencode() as I saw it suggested in a few places but had no luck (and didn't expect it to help as there is nothing fancy is in the URL?). $url = urlencode('https://192.168.1.59/'); $doc = new DOMDocument(); $doc->loadHtmlFile( $url ); $xpath = new DOMXPath( $doc ); $nodelist = $xpath->query( "/html/body/div[@class='applicationPalette']/table/tbody/tr[2]/td[@class='rightContentPane']/div[@class='pad10'][1]/table/tbody/tr[2]/td[@class='itemLargeFont']" ); I think I need to force HTTP 1.0 but I'm failing at working out how. Or am I wrong all together and it's something else? Thank you! Edited January 8, 2013 by shelluk Quote Link to comment https://forums.phpfreaks.com/topic/272850-domdocument-and-http-version-help/ Share on other sites More sharing options...
kicken Posted January 8, 2013 Share Posted January 8, 2013 Load the url contents using cURL or file_get_contents into first, then create the domdocument and populate it using the loadHTML() method. Quote Link to comment https://forums.phpfreaks.com/topic/272850-domdocument-and-http-version-help/#findComment-1404209 Share on other sites More sharing options...
shelluk Posted January 9, 2013 Author Share Posted January 9, 2013 Hi Kicken Thank you. That did the trick Shell Quote Link to comment https://forums.phpfreaks.com/topic/272850-domdocument-and-http-version-help/#findComment-1404411 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.