0
我试图自动执行将文本从网站传递到工具的过程,以便估计文本的阅读级别。但是,当我通过post方法传递url编码的文本时,我得到错误400错误的请求。错误的请求错误400请求库文件
article = 'The quick brown fox jumps over the lazy dog.'
headers = ({'Host': 'auto-ilr.ll.mit.edu',
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0',
'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
'Accept-Language': 'en-US,en;q=0.5',
'Accept-Encoding': 'gzip, deflate',
'DNT': '1',
'Referer': 'https://auto-ilr.ll.mit.edu/instant/',
'Connection': 'keep-alive'})
s = requests.Session()
#s.mount('https://', SSLAdapter())
s.mount('https://', MyAdapter())
try:
postdata = urllib.parse.urlencode({'Language': 'English', 'Text': article})
soup = s.post('https://auto-ilr.ll.mit.edu/instant/summary3', data=postdata, headers = headers, verify=False)
我不知道有什么区别,但也出现了少数情况下请求所经历和最终汤变量,从网站的文字结束了,但它是文本显示的网站做没有正确处理我包括的文本。
我感觉我缺少一些简单的东西。