Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/16.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何使用请求更改某物的HTML值?_Python_Python 3.x_Selenium_Python Requests_Python Requests Html - Fatal编程技术网

Python 如何使用请求更改某物的HTML值?

Python 如何使用请求更改某物的HTML值?,python,python-3.x,selenium,python-requests,python-requests-html,Python,Python 3.x,Selenium,Python Requests,Python Requests Html,我想更改网站中表单的HTML值。基本上只需在搜索算法中输入文本。 这是我的密码: import requests from bs4 import BeautifulSoup res = requests.get('https://website') soup = BeautifulSoup(res.text, features="lxml") findsearch = soup.find(id="search") 我想更改建议搜索的值,当您打印findsearch时,它以 type="tex

我想更改网站中表单的HTML值。基本上只需在搜索算法中输入文本。 这是我的密码:

import requests
from bs4 import BeautifulSoup

res = requests.get('https://website')
soup = BeautifulSoup(res.text, features="lxml")
findsearch = soup.find(id="search")
我想更改建议搜索的值,当您打印
findsearch
时,它以

type="text" value=""/>
如何使用请求更改值

好吧,看来你不能用请求来完成。这是我使用硒的解决方案。您还必须导入
webdriver

driver = webdriver.Chrome()
driver.get("http://website")
make_search = driver.find_element_by_id("ssearch")
make_search.click()
make_search.send_keys(search_term)
make_search.send_keys(Keys.RETURN)

你不能。为了模拟您想要的行为,您需要使用类似于Selenium的方法。如果您想在请求中复制此内容,则必须复制搜索栏发出的请求。想一想如何借助现代浏览器上的内置功能做到这一点,而这是你无法做到的。为了模拟您想要的行为,您需要使用类似于Selenium的方法。如果您想在请求中复制此内容,则必须复制搜索栏发出的请求。想一想如何借助现代浏览器的内置功能来实现这一点吗