python 实现登陆百度,欢迎指正,python指正,[Python]代码im
python 实现登陆百度,欢迎指正,python指正,[Python]代码im
[Python]代码
import urllib2,urllib,re,osimport sqlite3,cookielib,timedef LoginBaiDu(self,user,pwd): #设置 cookie = cookielib.CookieJar() cookieProc = urllib2.HTTPCookieProcessor(cookie) opener = urllib2.build_opener(cookieProc) urllib2.install_opener(opener) #请求 header = {'User-Agent':'Mozilla/5.0 (Windows NT 5.1; rv:6.0.2) Gecko/20100101 Firefox/6.0.2'} post = { 'username':user, 'password':pwd, 'tpl':'mn', 'u':'http://www.baidu.com/', 'psp_tt':0, 'mem_pass':'on' } post = urllib.urlencode(post) req = urllib2.Request( url='https://passport.baidu.com/?login', data=post, headers = header ) res = urllib2.urlopen(req).read(500) if 'passCookie' in res: flag = True else: flag = 'Login Fail:%s'%user return flag print (flag) #sb = SpiderBaiDu()LoginBaiDu('ggght','123456')
相关内容
- 豆瓣-只看楼主-pyquery版,豆瓣楼主-pyquery版,[Python]代码
- 豆瓣-只看楼主,豆瓣-楼主,[Python]代码#
- 编程制-工程图(基础篇),工程基础篇,添加线# -*- cod
- 编程制-工程图(基础篇),工程基础篇,添加一个点# -*-
- 度换算成度分秒,换算成度分秒,[Python]代码#!
- 利用google地图根据地址批量获取经纬度,,利用google地图
- 上个程序提到的isin,程序提到isin,[Python]代码de
- 提取MD5值一样(或不一样)的文件,和后缀名一样的文
- python发送HTTP请求,python发送请求,GET 方法>>> im
- try...finally 异常,try...finally,异常处理import t
评论关闭