发现了种快捷的爬虫方法
1.在“检查-Network”要模拟的post请求记录右键-Copy-Copy as cUrl(bash)
2.替换下面代码中文本内容,搞定
- import uncurl
- import requests
-
- response=eval(uncurl.parse('''
- curl 'http://xxxxx' \
- -H 'Accept: application/json, text/plain, */*' \
- -H 'Accept-Language: zh-CN,zh;q=0.9' \
- -H 'Connection: keep-alive' \
- -H 'Content-Type: application/json' \
- -H 'Origin: http://xxxxx' \
- -H 'Referer: http://xxxxx' \
- -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36' \
- --data-raw '{"id":"56"}' \
- --compressed \
- --insecure
- ''')).json()
- print(response['title'])