May-05-2020, 05:33 PM
hi there
i use python to do some beginner-webscraping.
i am using a simple basic-script that captures stock price data: the nice thing it should do this in real time, and then it should updating it self.
At the moment i have found out some issues: my soup is finding a empty list -
i use python to do some beginner-webscraping.
i am using a simple basic-script that captures stock price data: the nice thing it should do this in real time, and then it should updating it self.
At the moment i have found out some issues: my soup is finding a empty list -
import bs4 import requests from bs4 import BeautifulSoup def parsePrice(): `r=requests.get('`[`http://finance.yahoo.com/quote/FB?p=FB`](http://finance.yahoo.com/quote/FB?p=FB)`')` `soup=bs4.BeautifulSoup(r.text,"xml")` `price=soup.find_all('div',{'class':'My(6px) Post(r) smartphone_Mt(6px)'})[0].find('span').text` `return price` while True: `print('the current price_ '+str (parsePrice()))`
Traceback (most recent call last): File "C:\Users\Kasper\Documents\_f_s_j\_mk_\_dev_\bs\yahoo_finance.py", line 14, in <module> print('the current price_ '+str (parsePrice())) File "C:\Users\Kasper\Documents\_f_s_j\_mk_\_dev_\bs\yahoo_finance.py", line 10, in parsePrice price=soup.find_all('div',{'class':'My(6px) Post(r) smartphone_Mt(6px)'})[0].find('span').text IndexError: list index out of rangeafter musing some time i saw: well my soup.find_all is not finding anything: This causes the [0] since it is quite out of range because the find_all returns an empty list.

Wordpress - super toolkits a. http://wpgear.org/ :: und b. https://github.com/miziomon/awesome-wordpress :: Awesome WordPress: A curated list of amazingly awesome WordPress resources and awesome python things https://github.com/vinta/awesome-python