Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas as pd
- from bs4 import BeautifulSoup
- import requests
- import re
- wkn = 'DBX0G9'
- url = 'http://www.boerse-frankfurt.de/en/etfs/db+x+trackers+msci+world+information+technology+trn+index+ucits+etf+LU0540980496/price+turnover+history/historical+data'
- page = 1
- dates = []
- prices = []
- while True:
- soup = BeautifulSoup(requests.get(url+"#page="+str(page)).text)
- tmp_dates = soup.findAll('td', class_='column-date')
- tmp_dates = [re.sub('[\\nt\s]','',d.string) for d in tmp_dates]
- tmp_prices = soup.findAll('td', class_='column-price')
- tmp_prices = [float(re.sub('[\\nt\s]','',p.string)) for p in tmp_prices]
- if not tmp_prices or page > 2:
- break
- else:
- dates = dates + tmp_dates
- prices = prices + tmp_prices
- page = page + 1
- df = pd.DataFrame(index = dates)
- df[wkn] = prices
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement