Fri Apr 28 09:36:00 UTC 2023 inscode

上级 df352508
print('欢迎来到 InsCode')
\ No newline at end of file
import requests
from bs4 import BeautifulSoup
url = 'http://quote.eastmoney.com/ztb'
try:
res = requests.get(url, timeout=5)
soup = BeautifulSoup(res.text, 'html.parser')
except requests.exceptions.RequestException as e:
print(e)
exit()
print(soup)
hot_stocks = soup.select('#ztgc-box a')
print(hot_stocks)
if hot_stocks:
for stock in hot_stocks:
name = stock.select_one('.title a').text
code = stock.select_one('.title span').text
print(name, code)
else:
print('No hot stocks found.')
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册