Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import requests
- import numpy as np
- import pandas as pd
- import bs4
- url='https://uk.finance.yahoo.com/quote/AAPL/history?p=AAPL'
- r=requests.get(url)
- bsobj=bs4.BeautifulSoup(r.text,'html.parser')
- historical_table=bsobj.find('table',{'class':'W(100%) M(0)'})
- rows=historical_table.tbody.find_all("tr")
- data=[]
- for row in rows:
- cells = row.find_all("td")
- data.append([cell.text for cell in cells])
- pd.DataFrame(data)
Add Comment
Please, Sign In to add comment