首页 > 解决方案 > Selenium 对特定页面返回空白,但适用于其他页面

问题描述

我是 selenium 新手,我想用 selenium 爬取这个网站 http://www.customs.gov.cn/customs/302249/index.html,但是我得到一个这样的空白页面。但是当我尝试获取http://www.customs.gov.cn时,它可能会返回正确的结果。我不认为这是硒的问题,我搜索了很多,但不知道为什么,你能帮我吗?谢谢。这是我的代码:

    from selenium import webdriver # selenium import webdriver
    import time
    url = 'http://www.customs.gov.cn/customs/302249/index.html'
    driver = webdriver.Chrome()  # 声明调用Chrome
    driver.get(url) # 

这是返回的空白页。 在此处输入图像描述

标签: seleniumselenium-chromedriverweb-crawler

解决方案


请确保网址http://www.customs.gov.cn/customs/302249/index.html在 chrome 中以隐身窗口打开,然后重试。该网址对我不起作用。向客户报告空白页。您可能会看到页面的缓存版本。CTRL + F5 也将帮助您获得页面的新副本。

请记住,Selenium 只是要求浏览器打开一个页面。它不会打开页面本身。


推荐阅读