Last active
August 29, 2015 14:05
-
-
Save gtt116/4b26499b86ebf0ffc2b1 to your computer and use it in GitHub Desktop.
python http handler
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#coding=gbk | |
from httplib import HTTPConnection,HTTPResponse | |
# request' header | |
headers = { | |
"User-Agent":"Mozilla/5.0 (Windows; U; Windows NT 6.1; zh-CN; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13", | |
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8", | |
"Accept-Language":"zh-cn,zh;q=0.5", | |
"Accept-Charset":"GB2312,utf-8;q=0.7,*;q=0.7", | |
"Keep-Alive":"115", | |
"Connection":"keep-alive", | |
"Content-Type":"application/x-www-form-urlencoded", | |
} | |
username= "53521" | |
password="53521" | |
data = "number=%s&passwd=%s&select=cert_no&returnUrl=" % (username,password) | |
conn = HTTPConnection("210.33.91.65:8080") | |
conn.request("POST",url="/reader/redr_verify.php",body=data,headers=headers) | |
res = conn.getresponse() | |
if res.status == 302:print 'ok' | |
else: print 'err' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
#目标网址:url = http://www.google.com | |
#要发送的头部head | |
#要发送的数据data | |
req = urllib2.Request(url) | |
req.add_header(head) | |
req.add_data(data) | |
resp = urllib2.urlopen(req) | |
resp.read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment