You need to sign in or sign up before continuing.

UPDATE

上级 1b5c0ae9
import requests from redlines import Redlines
from bs4 import BeautifulSoup
url = 'http://quote.eastmoney.com/ztb' test = Redlines("The quick brown fox jumps over the lazy dog.")
try: assert test.compare(
res = requests.get(url, timeout=5) 'The quick brown fox walks past the lazy dog.') == "The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog."
soup = BeautifulSoup(res.text, 'html.parser')
except requests.exceptions.RequestException as e: assert test.compare(
print(e) 'The quick brown fox jumps over the dog.') == 'The quick brown fox jumps over the <del>lazy </del>dog.'
exit() \ No newline at end of file
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.
先完成此消息的编辑!
想要评论请 注册