0

I am trying to use wget to download the yahoo stock history file, https://query1.finance.yahoo.com/v7/finance/download/ARDM?period1=1504030392&period2=1506708792&interval=1d&events=history&crumb=TKe9axyOsuR

but it always reports an error code": Username/password authentication Failed.

However, if I visit that stock page https://finance.yahoo.com/quote/ARDM/history?p=ARDM I can click the datafile link, and download the CSV file without giving any user or password.

Any clue?

Rubén
  • 34,714
  • 9
  • 70
  • 166

1 Answers1

0

When you are going in via the browser the system is using your cached yahoo login details to go straight to the information using your cookie.

Set your authentication in your wget by using the following:

wget --user user --password pass http://example.com/

If you are not logging in to the server as seems to be the case here then you could try using two WGET using the first one to grab a cookie and the second one to download the data as follows:

wget -qO- --keep-session-cookies --save-cookies cookies.txt https://finance.yahoo.com/quote/ARDM/history?p=ARDM

followed by

wget -qO- --load-cookies cookies.txt https://query1.finance.yahoo.com/v7/finance/download/ARDM?period1=1504030392&period2=1506708792&interval=1d&events=history&crumb=TKe9axyOsuR

Paula Livingstone
  • 1,175
  • 1
  • 12
  • 21