Use python to log on to and verify the website! Developer online builder.com.cn updated on:
2008-05-25Author: dreamingk Source: csdn keywords:
Website
Login
Python
However, if you encounter a small problem, you need to log on to the website by ID to open the page and download it. Later, xyb gave two login codes to implement the functions I needed. Later, I read the Lib ref document of python2.3 and found that httplib can be used for implementation. The Code is as follows:
# Loginbbs. py
Import urllib, httplib
Params = urllib. urlencode ({'username': 'pytest ',
# Here is the login parameter for post. You can modify it as your own parameter.
'Password': 'pypassword ',
'Cookies _ time': 1,
'Islogin': true })
Headers = {"Content-Type": "application/X-WWW-form-urlencoded", "accept": "text/plain "}
# Build Headers
Conn = httplib. httpconnection ("music.popv.net: 80 ")
# Create an HTTP connection. Remember not to add 'HTTP: // 'to the address and add a port.
Conn. Request ("post", http://music.popv.net/popv/login.asp, Params, headers)
# Sending login requests
Response = conn. getresponse ()
# Get a reply
Print response. Status, response. Reason
# Obtain the Request status
Data = response. Read ()
# Obtain the webpage content after login
Conn. Close ()
# Closing a connection