huibao/backend/debug_cninfo.py

23 lines
797 B
Python
Raw Normal View History

import httpx
import asyncio
async def test_cninfo_details():
# Attempt 2: stockInfo
# Note: query params are usually distinct from body in POST, but let's try GET first or POST with params
# Actually, let's try GET.
url = "https://www.cninfo.com.cn/new/stock/stockInfo?orgId=9900005282&stockCode=002273"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36",
}
async with httpx.AsyncClient() as client:
try:
resp = await client.get(url, headers=headers)
print("Status:", resp.status_code)
print("Resp:", resp.text[:1000]) # Print first 1000 chars
except Exception as e:
print("Error:", e)
if __name__ == "__main__":
asyncio.run(test_cninfo_details())