硒柱法 [英] Selenium Post method

查看:76
本文介绍了硒柱法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试找到一种方法来获取通过无头浏览器执行的post方法的响应.

I'm trying to find a way to get the response of a post method executed through headless browser.

session = requests.Session()
session.get(<url here)
print session.cookies
r = session.post(url).content
print r

问题是响应r充满了JavaScript,并且我无法使用Selenium来执行它,因为它不支持POST方法(据我所知). 有什么想法吗?

The problem is that the response r is full of javascript and I can't use Selenium to execute it because it doesn't support the POST method (as far as I know). Any ideas?

推荐答案

您可以尝试使用> c0> :

扩展Selenium WebDriver类以包括请求功能 从Requests库中获取所需的Cookie, 请求标头处理.

Extends Selenium WebDriver classes to include the request function from the Requests library, while doing all the needed cookie and request headers handling.

示例:

from seleniumrequests import Firefox

webdriver = Firefox()
response = webdriver.request('POST', 'url here', data={"param1": "value1"})
print(response)

这篇关于硒柱法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆