我正在使用Chrome浏览器,如何发送带有硒的发帖请求?
我找到了这个答案Is there any way to start with a POST request using Selenium?,但是建议的解决方案有些过时了(2016年的最新更新) 过时的库https://pypi.org/project/selenium-requests/
我的代码:
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
driver = webdriver.Chrome(executable_path=driver_path, options=options)
response = driver.request('POST', url, data={"key_1": 'value_1', 'key_2': 'value_2'})
# AttributeError: 'WebDriver' object has no attribute 'request'
P.S。当找不到已经存在的答案时,我感到很惊讶。
答案 0 :(得分:0)
我相信Selenium专注于浏览器自动化,并且由于您无法直接在Chrome中进行POST,因此Selenium也不会提供这种功能。
通常,我认为您需要使用更通用的HTTP API而不是Selenium来进行发布并获取响应。
我想您也可以创建一个网页并进行开机自检,然后使用Selenium来操作该网页。