爬虫 登入电驴

import urllib
import urllib2
postdata=urllib.urlencode({
    'username':'spidertest',
    'password':'spidertest1',
    'continueURI':'http://www.verycd.com/',
    'fk':'',
    'save_cookie':'1',
    'safe_login':0,
    'login_submit':"登录"
})
header = {'User-Agent':'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Firefox/45.0'}
req = urllib2.Request(
    url = 'http://secure.verycd.com/signin',
    headers = header,
    data = postdata

)
result = urllib2.urlopen(req)
#print len(result.read())
print result.read()

你可能感兴趣的:(爬虫 登入电驴)