标签:range erer pandas info timestamp app apple mes imp
import datetime
import time
import json
import hashlib
import base64
import requests
import pandas
import browsercookie
from collections import Counter
import pandas
l = []
def get_token():
a = ‘9622‘
dt = datetime.datetime.now()
timestamp = str(dt.timestamp()).split(‘.‘)[0]
base_code = base64.b64encode((a + timestamp).encode("utf-8"))
data = hashlib.md5(base_code)
return data.hexdigest(), timestamp
safe, timestamp = get_token()
headers = {
‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36 QIHU 360SE‘,
‘Referer‘: ‘http://www.python-spider.com/challenge/1‘,
‘safe‘: safe,
‘timestamp‘: timestamp
}
cj = browsercookie.chrome()
c = Counter(‘a‘)
for i in range(1,86):
url = ‘http://www.python-spider.com/challenge/api/json?page=%s&count=14‘%str(i)
res = requests.get(url, headers=headers, cookies=cj)
try:
t = res.json()[‘infos‘]
l.append(t)
except Exception as e:
pass
p = []
for i in l:
for x in i:
data = x[‘message‘]
p.append({‘m‘:data})
df = pandas.DataFrame(p)
df[df.m.str.contains(‘招‘)]
标签:range erer pandas info timestamp app apple mes imp
原文地址:https://www.cnblogs.com/ruhai/p/13394609.html