【问题标题】:Selenium send post requestSelenium 发送帖子请求
【发布时间】:2020-06-28 13:29:08
【问题描述】:

我正在使用 Chrome 浏览器,如何使用 selenium 发送发布请求?

我找到了这个答案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'

附:当没有找到已经存在的答案时,我感到很惊讶。

【问题讨论】:

    标签: python selenium selenium-webdriver selenium-chromedriver


    【解决方案1】:

    我相信 Selenium 专注于浏览器自动化,由于你不能直接在 Chrome 中发布,Selenium 也不提供。

    一般来说,我认为您需要使用更通用的 HTTP API,而不是 Selenium,来 POST 并获取响应。

    我猜你也可以创建一个网页来发布,并使用 Selenium 来操作该网页。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-04-26
      • 2015-08-01
      • 1970-01-01
      • 1970-01-01
      • 2016-12-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多