简体   繁体   English

错误400 GET错误请求与Python请求

[英]Error 400 GET Bad Request with Python Requests

I'm trying to do some scraping on a web application using Python to extract information from it, and it is protected by HTTPBasicAuth . 我正在尝试使用Python从Web应用程序中抓取一些信息以从中提取信息,并且该方法受HTTPBasicAuth保护。

验证码

This is my code so far: 到目前为止,这是我的代码:

from lxml import html
import requests
from requests.auth import HTTPBasicAuth

headers = { 'User-Agent' : 'Mozilla/5.0 (Windows NT 10.0; WOW64; rv:67.0) Gecko/20100101 Firefox/67.0' }

page = requests.get('https://10.0.0.1:999/app/info' , verify = False , auth = ('user' , 'pass'), headers = headers)

print (page.content.decode())

But I'm getting this answer from print (page.content.decode()) : 但是我从print (page.content.decode())得到这个答案:

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
         "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 <head>
  <title>400 - Bad Request</title>
 </head>
 <body>
  <h1>400 - Bad Request</h1>
 </body>
</html>

What could be missing? 可能缺少什么?

Apparently I was using HTTPBasicAuth , and I had to use HTTPDigestAuth . 显然我正在使用HTTPBasicAuth ,并且我不得不使用HTTPDigestAuth Even though the website seemed to be using Basic Authentication, after an inspection of the traffic using Burp Proxy, I noticed it was using Digest Authentication. 即使该网站似乎正在使用基本身份验证,但在使用Burp Proxy检查流量后,我注意到它正在使用摘要身份验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM