我一直在寻找一周。我发现的所有答案都已过时或无效。
我正在尝试登录此网站http://ink361.com/app/login 我尝试单独使用请求,我尝试将请求与robobrowser混合以注入一些标头。 出于测试目的,我提供用户名和密码没有问题。
from robobrowser import RoboBrowser
import requests
headers = {
"Accept" : "application/json",
"Connection" : "keep-alive",
"Accept-Encoding" : "gzip, deflate",
"Accept-Language" : "en-US,en;q=0.5",
"Content-Length" : "50",
"Content-Type" : "application/x-www-form-urlencoded; charset=utf-8",
"Cookie" : '',
"DNT" : '1',
"Host" : "ink361.com",
"Referer" : "http://ink361.com/app/login",
"User-Agent" : "Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:54.0) Gecko/20100101 Firefox/54.0",
"X-Request" : "JSON",
"X-Requested-With" : "XMLHttpRequest"
}
s = requests.Session()
s.headers = headers
browser = RoboBrowser(session=s,history=True)
login_url = 'http://ink361.com/app/login'
browser.open(login_url)
forms = browser.get_forms()
print(forms)
我试图打印网页中的所有表单,但它需要永远然后它会引发
RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response',))
标题由于某种原因做了这件事。我尝试没有标题我得到一个空数组的表单。 我试着抓住这样的表格
form = browser.get_form(class_='modern-form')
print(form.fields)
我得到的字段都是空的..
答案 0 :(得分:1)