|
楼主 |
发表于 2019-4-14 11:40:20
|
显示全部楼层
回楼上wiselin的,参考网页json内容的结构,发送请求获取page和plan。 你用SPLASH的方法也发来看看学习学习
def get_page():
"""
根据偏移量获取网页
"""
global headers
# url请求参数
params = {'code':'pk10',
'plan':'0',
'size':'20',
'planSize':'20'
}
# 拼接url
url = base_url + urlencode(params)
# 请求url
response = requests.get(url, headers=headers)
return response.text
def get_plan(json_text):
"""
从json类型的文字中计划
"""
jt = json.loads(json_text)
title=jt['data']['planName']
#获取计划
data1=jt['data']['plan']
if data1:
for item in data1:
if item['plans'] is None: #
continue
beginIssue = item['beginIssue']
endIssue = item['endIssue']
plans = item['plans']
if item.__contains__('win'):
win = item['win']
else:
win='null'
winIssue=item['winIssue']
yield {
'title': title,
'bggin': beginIssue,
'-end': endIssue,
'plan':plans,
#'win':win,
'win':winIssue
} |
|