这是一篇用python代码自动登录的脚本,大家可以参考,看能不能开发点其他东东...
#!/usr/bin/env python
#web client post of python network program
import urllib,urllib2
def postNow():
url_login ='https://blog.51cto.com/login.php?'
body = (('pwuser','hahazhu0634'), ('pwpwd','51ctoisgood'), ('cktime','31536000'),('jumpurl','https://blog.51cto.com'),('step','2'))
opener=urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1)')]
urllib2.install_opener(opener)
req=urllib2.Request(url_login,urllib.urlencode(body))
u=urllib2.urlopen(req)
data=u.read()
outfile="51cto.html"
fsock = open(outfile, "w")
fsock.write(data)
fsock.close()
import webbrowser
webbrowser.open_new("51cto.html")
postNow()
如果想了解更多,请关注我们的公众号
公众号ID:opdevos
扫码关注