[Python] 纯文本查看 复制代码 import requests
from urllib.parse import urlencode
import json
import csv
import base64
from multiprocessing import Pool
url2='https://jhl.ke.seewo.com/live/plan/826510684487921665' #实际URL
url='https://jhl.ke.seewo.com/live/fetch?actionName=GET_PLAN_DETAIL&ts=1670989434716' #判断视频的URL
def checkurl(num):
apiUrl="http://live.seewo.com/live-server/live/v1/plan/8265"+num+"/open/detail"
strs='{"method":"GET","apiUrl":'+apiUrl+',"headers":{"userName":"","userType":"","userId":""},"baseURL":"http://live.seewo.com/live-server"}'
#print(strs)
result=base64.b64encode(strs.encode('utf-8')).decode('ascii')
#print(result)
headers={
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json',
"ApiExtend":result
}
response=requests.post(url=apiurl,headers=headers)
#result=json.loads(response.text)
if(response.status_code == 200):
print('https://jhl.ke.seewo.com/live/plan/8265'+num)
with open('url.txt', 'a+', encoding='utf-8') as f:
f.write('https://jhl.ke.seewo.com/live/plan/8265'+num+"\n")
f.close()
def main():
#for i in range (99999999999999):
# 保存进程
Process_list = []
# 创建并启动进程,限制进程数
p = Pool(30)
# for (cid,) in cids:
for i in range (11111151600000,99999999999999):
num=str(i).zfill(14)
# print(cid)
# exit()
p.apply_async(checkurl, args=(num,))
Process_list.append(p)
if i % 100000 ==0:
with open('url2.txt', 'a+', encoding='utf-8') as f:
f.write(str(i)+",")
f.close()
p.close()
p.join()
if __name__ == '__main__':
main()
运行一会儿就会自动关闭,程序哪儿有问题? |