您好我刮雅虎财经,我想打印的股票,如果大于50,但我没有反正这里工作是代码:为什么如果不工作?
import urllib2
from bs4 import BeautifulSoup as bs4
list = ["aapl","goog"]
i = 0
while i < len(list):
url = urllib2.urlopen("http://finance.yahoo.com/q?s="+ list[i] +"&q1=1")
soup = bs4(url,"html.parser")
for price in soup.find(attrs={'id':"yfs_l84_" + list[i]}):
print "something"
i += 1
if price > 200:
print price
您缩进事项应该会在for循环 – The6thSense
不能说缩进没有看到数据,但是在这里你打印的“东西”,为什么不打印出来的价格的价值,所以你可以看到它是否有你期望的价值。 –