当前位置:   article > 正文

stocks_stocks打印机标有

stocks打印机标有
  1. import urllib
  2. link="http://finance.yahoo.com/q/cp?s=^STI"
  3. html=urllib.urlopen(link).read()
  4. from sgmllib import SGMLParser
  5. import time
  6. class URLLister(SGMLParser):
  7. urls = []
  8. cou=0
  9. is_td=""
  10. def start_td(self, attrs):
  11. href = [v for k, v in attrs if k=='class']
  12. if 'yfnc_tabledata1' in href:
  13. self.is_td=1
  14. self.cou+=1
  15. def end_td(self):
  16. self.is_td=""
  17. def handle_data(self,text):
  18. if self.is_td:
  19. self.urls.append(text)
  20. while True:
  21. print 'Symbol ','Name ','LastTrade ','Change ','Volume '
  22. lister=URLLister()
  23. lister.feed(html)
  24. exclusive=['&','C',' N'] #hack
  25. names=[x for x in lister.urls if x!=' ' and not (x in exclusive) ]
  26. lenght=len(names)
  27. for i in range(0,lenght,7):
  28. print names[i:i+7]
  29. print '===================================================================='
  30. print 'will start to work in 1 min'
  31. time.sleep(60)

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/weixin_40725706/article/detail/725137
推荐阅读
相关标签
  

闽ICP备14008679号