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)
老薛主机,虽然是第一次分享这个商家的信息,但是这个商家实际上也有存在有一些年头。看到商家有在进行夏季促销,比如我们很多网友可能有需要的香港VPS主机季度及以上可以半价优惠,如果有在选择不同主机商的香港机房的可以看看老薛主机商家的香港VPS。如果没有记错的话,早年这个商家是主营个人网站虚拟主机业务的,还算不错在异常激烈的市场中生存到现在,应该算是在众多商家中早期积累到一定的用户群的,主打小众个人网站...
SugarHosts 糖果主机商也算是比较老牌的主机商,从2009年开始推出虚拟主机以来,目前当然还是以虚拟主机为主,也有新增云服务器和独立服务器。早年很多网友也比较争议他们家是不是国人商家,其实这些不是特别重要,我们很多国人商家或者国外商家主要还是看重的是品质和服务。一晃十二年过去,有看到SugarHosts糖果主机商12周年的促销活动。如果我们有需要香港、美国、德国虚拟主机的可以选择,他们家的...
今天9月10日是教师节,我们今天有没有让孩子带礼物和花送给老师?我们这边不允许带礼物进学校,直接有校长在门口遇到有带礼物的直接拦截下来。今天有看到Friendhosting最近推出了教师节优惠,VPS全场45折,全球多机房可选,有需要的可以看看。Friendhosting是一家成立于2009年的保加利亚主机商,主要提供销售VPS和独立服务器出租业务,数据中心分布在:荷兰、保加利亚、立陶宛、捷克、乌...