模块“请求”不通过登录

我正在尝试使用该requests模块从网站获取信息。要获取信息,您必须先登录,然后才能访问该页面。我查看了输入标签并注意到它们被调用login_username,login_password但由于某些原因post没有通过。我还在这里读到他通过在浏览另一页之前等待几秒钟来解决它,它也没有帮助..


这是我的代码:


import requests

import time


#This URL will be the URL that your login form points to with the "action" tag.

loginurl = 'https://jadepanel.nephrite.ro/login'


#This URL is the page you actually want to pull down with requests.

requesturl = 'https://jadepanel.nephrite.ro/clan/view/123'


payload = {

    'login_username': 'username',

    'login_password': 'password'

}


with requests.Session() as session:

    post = session.post(loginurl, data=payload)

    time.sleep(3)

    r = session.get(requesturl)

    print(r.text)


长风秋雁
浏览 142回答 1
1回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Python