我是Python新手,我试图使用请求模块登录到网站并打印出我的一些帐户信息。见下面的代码:使用Python请求登录网站
import requests
username = 'myusername'
password = 'mypassword'
URL = 'https://www.mmoga.com/login.php'
payload = {'email_address': username, 'password': password}
session = requests.session()
r = requests.post(URL, data=payload)
account = session.get('https://www.mmoga.com/shopping_cart.php')
print account.content
我也必须添加标题到requests.post
?
当我看到我看到
<div class="boxHeading">
<a href="mmoga.com/login.php"; title="- My Account -">- My Account -</a>
</div>
HTML源代码,但是我应该看到
<div class="boxHeading">
<a href="mmoga.com/account.php"; title="- My Account -">- My Account -</a>
</div>
您能否告诉我们您会得到什么回复,以及它与您的期望有什么不同? –
你读过这个... http://docs.python-requests.org/en/v2.0-0/user/authentication/ – jcfollower
@EricWilson当我看到html源码时,我看到