美丽的汤返回空列表

时间:2018-01-29 19:22:33

标签: python-3.x beautifulsoup web-crawler

import urllib.request
import re
from bs4 import BeautifulSoup as soup

tickersymbol = 'A'
url = 'https://finance.yahoo.com/quote/'+tickersymbol+'p='+tickersymbol 

htmlfile = urllib.request.urlopen(url) 
htmltext = htmlfile.read().decode('utf-8') 
page = soup(htmltext, "html.parser")
price = page.find_all('<span class="Trsdu(0.3s) Fw(b) Fz(36px) Mb(-4px) D(ib)"><!-- react-text: 331 -->(.+?)<!-- /react-text --></span>x')
print(price)

这会返回一个空列表,同时它应该返回股票的价格,该价格应该是'(。+?)'的位置。我做错了什么?

0 个答案:

没有答案
相关问题