小福利,python爬虫post方法小练习
import requests,json
headers={'user-agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36',
'Cookie':'acw_tc=76b20ff116509755162456196e09d8ec81ac35bbfe3d253620e36b7dace110; _zcy_log_client_uuid=00b48890-c55b-11ec-aaa8-4fc0f8436b0f',
'contentType': "application/json"
}
url='http://www.whggzy.com/front/search/category'
for j in range(5):
data={'categoryCode': "WorkDynamics",
'pageNo': j,
'pageSize': 15,
'utm': "sites_group_front.2ef5001f.0.0.00bf36f0c55b11ecaaa84fc0f8436b0f"
}
#data={"utm":"sites_group_front.2ef5001f.0.0.00bf36f0c55b11ecaaa84fc0f8436b0f","categoryCode":"WorkDynamics","pageSize":15,"pageNo":1}
res=requests.post(url,headers=headers,json=data)
# print(res.text)
a=res.json()
# print(a['hits'])
list=a['hits']['hits']
for i in range(15):
a=list[i]['_source']
print(a['title'])
# for i,j in a.items():
# print(i,j)
# print(list[0])
# print(list[1]['title'])
# print(list[2]['title'])
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)