Python 使用请求和美化组标识所有表单
我正在这样做:Python 使用请求和美化组标识所有表单,python,beautifulsoup,python-requests,Python,Beautifulsoup,Python Requests,我正在这样做: from bs4 import BeautifulSoup import urllib.request import requests website='http://www.website.ro/' r=urllib.request.urlopen(website).read() soup = BeautifulSoup(r,'lxml') form=soup.find('form') print(form) 假设该网站仅包含1个表单,我感兴趣的是: <div cla
from bs4 import BeautifulSoup
import urllib.request
import requests
website='http://www.website.ro/'
r=urllib.request.urlopen(website).read()
soup = BeautifulSoup(r,'lxml')
form=soup.find('form')
print(form)
假设该网站仅包含1个表单,我感兴趣的是:
<div class="search">
requests.post的第一个参数是url。有没有办法通过知道表单名称或从r.text获取表单触发的url
例如,MechanicalGroup的方法选择表单不需要url,它使用表单名称。(我不想使用mechanicalsoup)我想说的是,您必须查看通过Chrome开发者工具之类的工具手动触发的请求,然后使用该URL
r = requests.post('http://httpbin.org/post', data = {'key':'value'})