I need to analyze three years of historical stocks and fetch data from website: "https://finance.yahoo.com/quote/AAPL/history?period1=1476255600&period2=1570863600&interval=1d&filter=history&frequency=1d" however, I check the data frame only 3 months were given.
I tried to change different data period, I did see the changes in the websites. However, I still can get 3 months of data regardless of any changes periods of time. I used url request as follows:
url="https://finance.yahoo.com/quote/AAPL/historyperiod1=1476255600&period2=1570863600&interval=1d&filter=history&frequency=1d " #open link html = urlopen(url) soup = BeautifulSoup(html)
data = []
allrows= soup.find_all("tr")
for row in allrows :
    row_list = row.find_all("td")
    dataRow= []
    for cell in row_list:
        dataRow.append(cell.text)
    data.append(dataRow)
data = data[6:] 
#Check data head and tail to ensure the dataframe is correct
df.columns = header_list
print(df.head())
print(df.tail())
----------
          Date    Open    High     Low  Close* Adj Close**      Volume
0  Oct 04, 2019  225.64  227.49  223.89  227.01      227.01  34,619,700
1  Oct 03, 2019  218.43  220.96  215.13  220.82      220.82  28,606,500
2  Oct 02, 2019  223.06  223.58  217.93  218.96      218.96  34,612,300
3  Oct 01, 2019  225.07  228.22  224.20  224.59      224.59  34,805,800
4  Sep 30, 2019  220.90  224.58  220.79  223.97      223.97  25,977,400
                                                 Date    Open    High     
Low  \
91                                       May 29, 2019  176.42  179.35  
176.00   
92                                       May 28, 2019  178.92  180.59  
177.91   
93                                       May 24, 2019  180.20  182.14  
178.62   
94                                       May 23, 2019  179.80  180.54  
177.81   
95  *Close price adjusted for splits.**Adjusted cl...    None    None    
None   
    Close* Adj Close**      Volume  
91  177.38      176.71  28,481,200  
92  178.23      177.56  27,948,200  
93  178.97      178.29  23,714,700  
94  179.66      178.98  36,529,700  
95    None        None        None
#check data shape
df.shape
(96, 7)