【发布时间】:2021-05-05 14:30:05
【问题描述】:
我正在尝试导航到以下页面并提取 html https://www.automobile.it/annunci?b=data&d=DESC,但每次我调用 get() 方法时,看起来网站都会将我重定向到另一个页面,始终是相同的页面,即 @987654322 @。
这是我正在运行的简单代码:
from selenium import webdriver
driver = webdriver.Chrome(executable_path=ex_path)
driver.get("https://www.automobile.it/annunci?b=data&d=DESC")
html=driver.page_source
如果我使用请求模块做同样的事情,我不会被重定向
import requests
html=requests.get("https://www.automobile.it/annunci?b=data&d=DESC")
我不明白它为什么会这样,有什么想法吗?
【问题讨论】:
-
听起来 cookie 正在影响您的抓取。
标签: python selenium web-scraping