python登陆网页并处理网站s es s ion和c ookie这是一个python通过urllib直接登陆网站并处理网站的session和c ookieimport cookielib,urllib,urllib2login=‘ismellbacon123@yahoo.com’password=‘login’
#Enable cookie support for urllib2cookiejar=cookielib.CookieJar()urlOpener=urllib2.build_open er(urllib2.HTTPCookieProc es sor(c ookiejar))#Send login/password to the site and get the session cookievalues={‘login’ :login, ‘password’ :pas sword}data=urllib.ur lenc ode(values)reques t=urllib2.Reques t(http://www.imdb.c om/regis ter/login,data)url=urlOpener.open(request)#Our cookiejar automatically receives the cookiesp ag e=url.r e ad(500000)
#Make sure we are logged in by checking the presence of the cookie id.#(which is the c ookie containing the s es sion identifier.)if not ‘id’ in[cookie.name for cookie in cookiejar] :raise ValueError,Login failed with login=%s,password=%s%(login,password)print We are logged in!
#Make another request with our session cookie
#(Our urlOpener automatically uses cookies from our cookiejar)url=urlOpener.open(‘http://imdb.c om/find?s=all q=grave’)
p ag e=url.r e ad(200000)
官方网站:点击访问青云互联活动官网优惠码:终身88折扣优惠码:WN789-2021香港测试IP:154.196.254美国测试IP:243.164.1活动方案:用户购买任意全区域云服务器月付以上享受免费更换IP服务;限美国区域云服务器凡是购买均可以提交工单定制天机防火墙高防御保护端口以及保护模式;香港区域购买季度、半年付、年付周期均可免费申请额外1IP;使用优惠码购买后续费周期终身同活动价,价格不...
今天看到群里的老秦同学在布局自己的网站项目,这个同学还是比较奇怪的,他就喜欢用这些奇怪的域名。比如前几天看到有用.in域名,个人网站他用的.me域名不奇怪,这个还是常见的。今天看到他在做的一个范文网站的域名,居然用的是 .asia 后缀。问到其理由,是有不错好记的前缀。这里简单的搜索到.ASIA域名的新注册价格是有促销的,大约35元首年左右,续费大约是80元左右,这个成本算的话,比COM域名还贵。...
[六一云迎国庆]转盘活动实物礼品美国G口/香港CTG/美国T级超防云/物理机/CDN大促销六一云 成立于2018年,归属于西安六一网络科技有限公司,是一家国内正规持有IDC ISP CDN IRCS电信经营许可证书的老牌商家。大陆持证公司受大陆各部门监管不好用支持退款退现,再也不怕被割韭菜了!主要业务有:国内高防云,美国高防云,美国cera大带宽,香港CTG,香港沙田CN2,海外站群服务,物理机,...