下面是我正在使用的代码
import requests
import sys
import urllib, urllib2, cookielib
USERNAME = ''
PASSWORD = ''
URL = 'https://apps1.coned.com/cemyaccount/MemberPages/MyAccounts.aspx?lang=eng'
def main():
# Start a session so we can have persistant cookies
session = requests.session()
# This is the form data that the page sends when logging in
login_data = {
'ctl00$Main$Login1$UserName': USERNAME,
'ctl00$Main$Login1$Password': PASSWORD,
'submit': 'Sign In',
}
# Authenticate
r = session.post(URL, data=login_data)
# Trying to access a page that requires you to be logged in
r = session.get("https://apps1.coned.com/cemyaccount/MemberPages/MyAccounts.aspx?lang=eng")
print r.status_code
print r.headers
print r.content
if __name__ == '__main__':
main()
你好
我是 python 新手,面临一些问题。
登录后我需要页面的源页面,但问题是我也能够登录并获取代码,但是当我看到源页面时,我正在获取母版页的页面源代码,即标题而不是正文。
有人可以帮我吗?