python版本:3.5
源代码:
#coding=utf8
import urllib.request
import urllib.parse
from common.common_file import write_to_file
'''
模拟在以下地址登录:
http://www.iqianyue.com/mypost/
'''
#需要发送的地址
url = "http://www.iqianyue.com/mypost/"
#需要请求的数据
data = {
"name":"test001",
"pass":"654321",
}
mydata = urllib.parse.urlencode(data).encode("utf-8")
req = urllib.request.Request(url,mydata)
# req.add_header()
data = urllib.request.urlopen(req).read()
print(data)
write_to_file("E:\\test\\2016121901.html","wb",data)