|

楼主 |
发表于 2019-11-30 21:06:20
|
显示全部楼层
- # -*- coding: utf-8 -*-
- """
- Created on Sat Jun 29 19:52:11 2019
- @author: FernandoZeng
- 说明:运行目录会生成一个list.txt储存淘到的码
- 需要修改两个参数,参照下文注释
- """
- import requests
- import time
- header={
- 'Host': 'huodong2.4399.com',\
- 'Connection': 'keep-alive',\
- 'Content-Length': '38',\
- 'Accept': 'application/json, text/javascript, */*; q=0.01',\
- 'Origin': 'http://huodong2.4399.com',\
- 'X-Requested-With': 'XMLHttpRequest',\
- 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/75.0.3770.100 Safari/537.36',\
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',\
- 'Referer': 'http://huodong2.4399.com/gifts/2019znq_17.html',\
- 'Accept-Encoding': 'gzip, deflate',\
- 'Accept-Language': 'zh-CN,zh;q=0.9',\
- }
- loginurl='http://ptlogin.4399.com/ptlogin/login.do?v=1'
- logindata={'loginFrom':'uframe',\
- 'postLoginHandler':'refreshParent',\
- 'layoutSelfAdapting':'true',\
- 'externalLogin':'qq',\
- 'displayMode':'popup',\
- 'layout':'vertical',\
- 'appId':'huodong',\
- 'gameId':'',\
- 'css':'',\
- 'redirectUrl':'',\
- 'sessionId':'',\
- 'mainDivId':'popup_login_div',\
- 'includeFcmInfo':'false',\
- 'userNameLabel':'4399%E7%94%A8%E6%88%B7%E5%90%8D',\
- 'userNameTip':'%E8%AF%B7%E8%BE%93%E5%85%A54399%E7%94%A8%E6%88%B7%E5%90%8D',\
- 'welcomeTip':'%E6%AC%A2%E8%BF%8E%E5%9B%9E%E5%88%B04399',\
- 'username':'账户',\
- #此处修改为4399用户名
- 'password':'密码',\
- #此处修改为4399账户密码
- 'autoLogin':'on'}
- url="http://huodong2.4399.com/gifts/ajax.php"
- d={'op':'taoma','hd_id':'17','t':'0.9744178929038112'}
- page=requests.Session()
- page.headers=header
- page.post(loginurl,data=logindata)
- while(True):
-
- text = page.post(url,data=d).text
-
- if(text.find("taoma_out_limit")!=-1):
- time.sleep(30)
- else:
- f=open('list.txt','a')
- malist=[text[29:45]+'\n',text[48:64]+'\n',text[67:83]+'\n']
- print(malist)
- f.writelines(malist)
- f.close()
复制代码 |
|