如何使用beautifulsoap和python创建一个受密码保护的网站?

2024-04-19 06:02:36 发布

您现在位置:Python中文网/ 问答频道 /正文

https://khaiexch.com/我怎样才能浏览这个网站。 我正在尝试类似的东西,但它给出了403作为回应

login_url = 'https://khaiexch.com/login/login_action'
login_data = {
    "email": "***", 
      "password": "****", 
    "compute": "****",
    "submitted": "****"
    }
r = requests.post(login_url, data=login_data)

但是上面的代码给了我403个错误,谁能告诉我怎么才能刮取这个网站


Tags: 代码httpscomurldata网站emaillogin
1条回答
网友
1楼 · 发布于 2024-04-19 06:02:36

尝试使用get方法进行请求,并使用类似以下的头:

import requests

login_url = 'https://khaiexch.com/login/login_action'
login_data = {
    "email": "***", 
    "password": "****", 
    "compute": "****",
    "submitted": "****"
    }
headers     = {'User-Agent': 'okhttp/3.12.1'}
r = requests.get(login_url, data=login_data, headers=headers)
result = r.status_code
print (result)

相关问题 更多 >