python3登录网页(163邮箱)实例,,#-*-coding
python3登录网页(163邮箱)实例,,#-*-coding
#-*-coding:utf-8-*-
importurllib
importhttp.cookiejarascookielib
importurllib.requestasurllib2
#创建cookie
cookie=cookielib.CookieJar()
cookieProc=urllib2.HTTPCookieProcessor(cookie)
opener=urllib2.build_opener(cookieProc)
urllib2.install_opener(opener)
#登录网页
data={‘username‘:‘xxx@163.com‘,‘password‘:‘xxxxxx‘,‘type‘:1}
post_data=urllib.urlencode(data).encode(‘UTF-8‘)
header={‘User-Agent‘:‘Mozilla/5.0(Windows;U;WindowsNT6.1;en-US;rv:1.9.1.6)Gecko/20091201Firefox/3.5.6‘}
request=urllib2.Request(url=‘http://reg.163.com/logins.jsp‘,data=post_data,headers=header)
res=urllib2.urlopen(request).read().decde(‘UTF-8‘)
#如果上面代码没有install_opener(),则这里可用:opener.open(req).read()方法来获取内容。
print(res)
python3登录网页(163邮箱)实例,编橙之家,mamicode.com
python3登录网页(163邮箱)实例
相关内容
- Python3 requests模块实现模仿浏览器+代理访问,,import re
- python 课后习题 猜数游戏,,4.1 猜数游戏。在
- Python GUI篇——关不掉的小窗口,,Python GUI
- 【Python】从汇率转换算法谈起,,CurStr = i
- python用socket模拟post请求,,今天用python的
- Python3基础 一个类中 属性与方法重名时,属性会覆盖方
- python下用OpenCV的圆形检测,,写在文章前这些天因为
- Python--函数return多个值,,# 函数如果有多个r
- Python中进程无法结束的处理办法,,1.方法一 htt
- Python函数实现99乘法表,,def printL
评论关闭