我是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源碼時,我看到