fork(7) download
  1. from bs4 import BeautifulSoup
  2. import requests
  3. url = 'http://m...content-available-to-author-only...f.com/companies/ICICI-Bank-Ltd/14030056?src=comp_srch'
  4.  
  5. """to do -> reaching a stock's page on rediff, converting str(delta) into float, improving upon the way u get delta, is conversion to str is neccessery??"""
  6. source_code = requests.get(url)
  7. code = BeautifulSoup(source_code.text)
  8. # print(code)
  9. for l in code.findAll('span', {'id' : 'ChangePercent'}):
  10. s = str(l)
  11. perc = s.index('%')
  12. delta = s[perc-5:perc]
  13. if delta[0] != '-' :
  14. s = s[25:29]
  15. delta = s
  16. delta = float(delta)
  17. print(delta)
  18.  
Runtime error #stdin #stdout #stderr 0.02s 8688KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 1, in <module>
ImportError: No module named 'bs4'