Guest User

Untitled

a guest
Jan 22nd, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.41 KB | None | 0 0
  1. import requests
  2. import numpy as np
  3. import pandas as pd
  4. import bs4
  5. url='https://uk.finance.yahoo.com/quote/AAPL/history?p=AAPL'
  6. r=requests.get(url)
  7. bsobj=bs4.BeautifulSoup(r.text,'html.parser')
  8. historical_table=bsobj.find('table',{'class':'W(100%) M(0)'})
  9. rows=historical_table.tbody.find_all("tr")
  10. data=[]
  11. for row in rows:
  12. cells = row.find_all("td")
  13. data.append([cell.text for cell in cells])
  14. pd.DataFrame(data)
Add Comment
Please, Sign In to add comment