Python 自动登录enoctus为自动下单做准备

2,685次阅读

共计 829 个字符,预计需要花费 3 分钟才能阅读完成。

#coding:utf-8
import urllib
import http.cookiejar

uname="用户名"
pword="密码"
url = "https://einstein.enoctus.co.uk/dologin.php"
postdata =urllib.parse.urlencode({
    'username': uname,
    'password': pword
}).encode('utf-8')
header = {
"Accept":"text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Encoding":"utf-8",
"Accept-Language":"zh-cn,zh;q=0.8,en-us;q=0.5,en;q=0.3",
"Connection":"keep-alive",
"Host":"einstein.enoctus.co.uk",
"Referer":"https://einstein.enoctus.co.uk/clientarea.php",
"User-Agent":"Mozilla/5.0 (Windows NT 6.1; WOW64; rv:32.0) Gecko/20100101 Firefox/32.0"
}
req = urllib.request.Request(url,postdata,header)
##print(urllib.request.urlopen(req).read().decode('utf-8'))

#自动记住 cookie
cj = http.cookiejar.CookieJar()
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor(cj))
r = opener.open(req)
print(r.read().decode('utf-8'))

正文完
 0
Blood.Cold
版权声明:本站原创文章,由 Blood.Cold 于2019-10-02发表,共计829字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。