UPDATE

上级 1b5c0ae9
import requests
from bs4 import BeautifulSoup
from redlines import Redlines
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.')
test = Redlines("The quick brown fox jumps over the lazy dog.")
assert test.compare(
'The quick brown fox walks past the lazy dog.') == "The quick brown fox <del>jumps over </del><ins>walks past </ins>the lazy dog."
assert test.compare(
'The quick brown fox jumps over the dog.') == 'The quick brown fox jumps over the <del>lazy </del>dog.'
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册