我正在编写我的第一个pythonwebscraper,但是在编写代码以获取所需的数据时遇到了问题。你知道吗
以下是我目前的代码:
import bs4 as bs
import urllib.request
source = urllib.request.urlopen ('http://finviz.com/screener.ashx?v=340&s=ta_topgainers')
soup = bs.BeautifulSoup(source, "html.parser")
#Ticker = 'quote.ashx?t'
print (Ticker)
我想从网站上提取以下代码:
<a href="quote.ashx?t=ETRM&ty=c&p=d&b=1">
这是整个系列,但我只对上面的部分感兴趣:
<a href="quote.ashx?t=ETRM&ty=c&p=d&b=1"><img src="chart.ashx?t=ETRM&ta=1&ty=c&p=d&s=l" alt="" width="700" height="340" border="0"/></a></td>
具体地说,我想拉出股票代码符号,在本例中是$ETRM。我想把所有的股票代码符号从上面的页面是在上面的格式。你知道吗
我试图隔离quote.ashx?t
,但它只是返回页面的整个源代码。你知道吗
输出:
通过将
href
值与CSS selector部分匹配,可以找到所需的链接:相关问题 更多 >
编程相关推荐