爬虫post请求时携带json形式request payload
import json
import requests
from lxml import etree
url = 'https://tass.com/userApi/categoryNewsList'
header = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) '
'Chrome/90.0.4430.212 Safari/537.36',
"Content-Type": "application/json"
}
proxies = {"http": "http://192.168.50.65:1080",
"https": "https://192.168.50.65:1080"}
data = {"excludeNewsIds": "1297659,1297639,1297633,1297619",
"limit": 20,
"sectionId": 4954,
"imageSize": 434,
"type": "all"}
html = requests.post(url=url, json=data, headers=header, proxies=proxies).text
print(html)
data必须为json格式双引号不然不得行