Created
March 25, 2023 22:39
-
-
Save reefwing/708cd4ea9aba983faa55ebe4ffe6567a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pandas as pd | |
import requests | |
# Set the ticker value | |
ticker = "STW.AX" | |
# Define the URL to fetch data from Yahoo Finance | |
url = f"https://finance.yahoo.com/quote/{ticker}/history?p={ticker}" | |
# Send a GET request to the URL and retrieve the HTML content | |
response = requests.get(url) | |
html_content = response.content | |
# Use pandas to extract the data from the HTML content | |
df_list = pd.read_html(html_content) | |
# The data we want is usually the first item in the list of dataframes | |
df = df_list[0] | |
# Print the extracted data | |
print(df) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment