Python get获取页面cookie
来源:互联网 发布:易用软件 编辑:程序博客网 时间:2024/06/06 12:50
#! /usr/bin/env python
#coding=utf-8
# -*-coding:utf-8 -*-
#encoding=utf-8
import urllib
import urllib2
import httplib
cj=''
header={'Host':'218.94.26.135',
'Accept-Language':'zh-CN',
'Connection':'Keep-Alive',
'Accept-Encoding':'gzip,deflate',
'Accept':'text/html, application/xhtml+xml, */*',
'User-Agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/28.0.1500.71 Chrome/28.0.1500.71 Safari/537.36'
}
con=httplib.HTTPConnection('218.94.26.135') #建立请求:218.94.26.135/casequery/KT_index.jsp?fydm=320100%20A00
con.request(method='GET',url='/casequery/KT_index.jsp?fydm=320100%20A00',headers=header)
res=con.getresponse()
res.read() #调用read函数以后,才能获取content。
con.close()
if res.getheader('Set-Cookie')!=None: #判断是否存在Set-Cookie,有的话,将cookie保存起来
cj=res.getheader('Set-Cookie').split(';')[0]
print cj
else:
print 'got no cookie'
#coding=utf-8
# -*-coding:utf-8 -*-
#encoding=utf-8
import urllib
import urllib2
import httplib
cj=''
header={'Host':'218.94.26.135',
'Accept-Language':'zh-CN',
'Connection':'Keep-Alive',
'Accept-Encoding':'gzip,deflate',
'Accept':'text/html, application/xhtml+xml, */*',
'User-Agent':'Mozilla/5.0 (X11; Linux i686) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/28.0.1500.71 Chrome/28.0.1500.71 Safari/537.36'
}
con=httplib.HTTPConnection('218.94.26.135') #建立请求:218.94.26.135/casequery/KT_index.jsp?fydm=320100%20A00
con.request(method='GET',url='/casequery/KT_index.jsp?fydm=320100%20A00',headers=header)
res=con.getresponse()
res.read() #调用read函数以后,才能获取content。
con.close()
if res.getheader('Set-Cookie')!=None: #判断是否存在Set-Cookie,有的话,将cookie保存起来
cj=res.getheader('Set-Cookie').split(';')[0]
print cj
else:
print 'got no cookie'
- Python get获取页面cookie
- JS获取页面的COOKIE
- python利用cookie跳过验证码登录,直接获取二级页面内容
- python 直接用账号密码cookie登陆人人网获取页面
- python使用requests获取cookie
- python获取服务器响应cookie
- python网络爬虫学习(一)通过GET和POST方式获取页面内容
- JSP页面中获取Cookie的值
- jquery cookie 跨页面 获取值undefined
- php页面session,cookie,post,get这四种传值方法
- Post/Get方式获取Web页面
- GET方法 页面间参数传递获取
- js获取页面get传递的参数
- C#--Get获取Web前端页面Html
- golang web开发获取get、post、cookie参数
- cookie只能当前页获取,其他页面获取不了。
- Python爬虫获取cookie:利用selenium
- Python 获取cookie只sid值
- C# 读取txt文件 FileStream,StreamReader,StreamWriter
- T510拆机有感
- error PRJ0003 : 生成“cl.exe”时出错 解决方案
- 类的初始化顺序
- 关于无线网络中几个名词WPS,PSK,WPA,WPA2等名词的解释以及WPA的破解
- Python get获取页面cookie
- ZOJ 1455
- shell编程
- mongodb和spring集成中MongoTemplate的总结是使用方法
- 常用SVN命令总结
- 分拣螺钉
- apache TIME_WAIT的解决办法
- hdu1754(裸线段树) 改点问区间最大值
- Linux下安装tpacpi-bat 控制thinkpad 充电阈值