简体   繁体   English

phantomjs总是返回在特定网站上找不到的页面

[英]phantomjs always return page not found on a particular website

im trying to get sport matches resul from this website 我正在尝试从此网站获取体育比赛结果

http://www.oddsportal.com http://www.oddsportal.com

but any address from this website that i try i end up with page not found 但是我尝试从该网站获得的任何地址都以找不到页面结尾

while it opens in my own browser 当它在我自己的浏览器中打开时

here is a sample code 这是示例代码

var webPage = require('webpage');
var page = webPage.create();

page.onConsoleMessage = function(msg) {
  console.log(msg);
}

page.open('http://oddsportal.com', function(status) {

  page.evaluate(function() {
    console.log(document.getElementsByTagName('body')[0].innerHTML);
  });
  phantom.exit();

});

i dont know how they are blocking phantom js and i've no idea where to start ..... 我不知道他们如何阻止幻影js,我也不知道从哪里开始.....

is there anything in phantom js headers that would alert them ? 幻影js标头中有什么可以提醒他们的吗?

i'll appreciate any suggestion or advice on how can i solve this 我将不胜感激如何解决此问题的任何建议或意见

here is that website output 这是该网站的输出

                                    <a href="http://www.oddsportal.com">
                                        <img src="logo.jpg" />
 </p>

                                    <div id="main" class="home">
                                        <div id="breadcrumb">
                                            <strong>The page you requested is not available.</strong>
                                        </div>
                                    <hr class="hidden">
                                        <div id="col-content">
                                            <h1>Page not found</h1>
                                            <p>This page not exist on OddsPortal.com!</p>
                        </div>
                                        <div class="break"></div>
                                        <hr class="hidden">
                                    </div>
                                    <div id="footer">
                                        <p class="l">Copyright © 2008-12 OddsPortal.com (v)</p>
                                        <div class="break"></div>
                        </div>

Try changing the user agent using page.settings.userAgent : 尝试使用page.settings.userAgent更改用户代理:

var webPage = require('webpage');
var page = webPage.create();

page.settings.userAgent = 'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36';

//...

Source: PhantomJS Docs 资料来源: PhantomJS文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM