1

I have run into this problem before and still don't know what I can do, so I figured I would ask here.

Say I have a website like: https://www.macrotrends.net/stocks/charts/AAPL/apple/stock-price-history

if you scroll down a bit there is a red button "Download Data". This downloads the csv.

I would like to read this csv into a data frame in Python or R. Whatever 'read csv' function I use, I need a url. My question is: How do I get a url for this csv? That's all I need to know.

1 Answer 1

2

It sounds like you are looking for the url for this specific case, and not a general solution for similar cases, if that is the case, I think this is the url you are looking for:

http://download.macrotrends.net/assets/php/stock_data_export.php?t=AAPL

The way I found it was

  1. Load the url from the question
  2. RMB on download button and click Inspect Element (I used Opera, but I know chrome has an equivalent)
  3. Open the console (tab on top of inspection pane)
  4. Clicked the red download button you mentioned
  5. Watched the console until I saw something that looked like it was fetching something and tried that url

It seems like a bit of a hack, but it downloads the data.

Since you mentioned python, @HEADLESS_0NE has a good answer on how to Use python requests to download CSV

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks for the answer, I figured I could get it by expecting elements, but beyond that I had no idea, so now I can apply this to other sites that do the same thing

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.