Python Can';无法通过请求模拟浏览器行为

Python Can';无法通过请求模拟浏览器行为,python,selenium-webdriver,python-requests,Python,Selenium Webdriver,Python Requests,我正在尝试向网站发送post请求以获得json响应。当我点击一个链接时,我可以在Chrome Inspector中看到json响应,但我可以使用请求获得它。 首先,我尝试使用请求会话首先获取cookies并在post请求中使用它们,但没有成功 session = requests.Session() session.get('http://www.auchandrive.fr/drive/pagestatique.pagetemplate.popuphandler.popinchangement

我正在尝试向网站发送post请求以获得json响应。当我点击一个链接时,我可以在Chrome Inspector中看到json响应,但我可以使用请求获得它。 首先,我尝试使用请求会话首先获取cookies并在post请求中使用它们,但没有成功

session = requests.Session()
session.get('http://www.auchandrive.fr/drive/pagestatique.pagetemplate.popuphandler.popinchangementmagasin.changermag/537?t:ac=PAGE_STATIQUE_ENGAGEMENTS')
response = session.post('http://www.auchandrive.fr/drive/rayon.productlist.pagination_0.topage/1?t:ac=3686973/3686997')
print response.text
其次,我使用Selenium+PhantomJS获取cookies,并在请求中使用它们,没有结果

browser = webdriver.PhantomJS(PHANTOMJS_PATH)
browser.get('http://www.auchandrive.fr/drive/pagestatique.pagetemplate.popuphandler.popinchangementmagasin.changermag/537?t:ac=PAGE_STATIQUE_ENGAGEMENTS')
all_cookie = {}
for cookie in browser.get_cookies():
    all_cookie[cookie['name']] = cookie['value']
rep = requests.post('http://www.auchandrive.fr/drive/rayon.productlist.pagination_0.topage/1?t:ac=3686973/3686997', cookies=all_cookie)
它只在我手动从Chrome获取cookies时起作用。 我看不出有什么问题

session = requests.Session()
session.get('http://www.auchandrive.fr/drive/pagestatique.pagetemplate.popuphandler.popinchangementmagasin.changermag/537?t:ac=PAGE_STATIQUE_ENGAGEMENTS')
response = session.post('http://www.auchandrive.fr/drive/rayon.productlist.pagination_0.topage/1?t:ac=3686973/3686997')
print(response.json)
使用
json
属性将获取json响应。您还可以使用请求进行持久会话,因此提供cookie

response.cookies #The cookies attribute

我编辑了这个问题以包含urlsWhat you thing to get?我试图获得json格式的产品列表(我可以在Chrome中看到),但我得到的是html