• 周二. 9月 27th, 2022

5G编程聚合网

5G时代下一个聚合的编程学习网

热门标签

雪球网接口测试

admin

11月 28, 2021
import requests
from bs4 import BeautifulSoup
import lxml

headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:61.0) Gecko/20100101 Firefox/61.0",
"Cookie": "xq_a_token=b02adfc63102d5b06db993fb320f0a7524962682"}
url = "https://xueqiu.com/stock/search.json"
param = {"code": "中国平安", "size": 3, "page": 1}
res = requests.get(url=url, params=param, headers=headers)
res.encoding = "utf-8"
# 获取json格式
print(res.json())
# 获取文本格式
print(res.text)
# 获取cookie信息
print(res.request.headers.get("Cookie"))
# 断言
assert "中国平安" in res

发表回复

您的电子邮箱地址不会被公开。