Selenium和Phantomjs页面加载失败

2024-06-01 05:20:58 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图从包含在这个url:http://www.oddsportal.com/darts/world/pdc-world-championship/results/中的页面捕获信息。我使用的是selenium和phantomJS()(我使用npm安装了phantomJS,这对于其他应用程序也很好,请注意,为了复制我的代码,您需要下载二进制文件或使用npm)。以下是我的尝试:

from time import sleep
from selenium import webdriver
url = 'http://www.oddsportal.com/darts/world/pdc-world-championship/results/'
waiting_period = 6
driver = webdriver.PhantomJS()
driver.get(url)
sleep(waiting_period)
print driver.page_source

当我这样做的时候,我得到的html和我的目标页面完全不同。它包含消息“您请求的页面不可用”。我想知道这是因为缺少设置/cookies,还是因为phantomjs执行javascript?在

ulimate,我想从id='tournamentTable'的div中捕获信息,该信息在通过浏览器加载页面时显示。在


Tags: com信息httpurlworldwwwdriverselenium