0

I am getting a 404 from urllib2. Despite the fact that the link works fine in my browser...

import urllib2
import numpy
import scipy.stats
import csv
import httplib

f1 = urllib2.urlopen("http://ichart.finance.yahoo.com/table.csv?s=GOOG&a=01&b=1&c=2010&d=01&e=01&f=2011&g=d&ignore=.csv")
f2 = urllib2.urlopen("http://ichart.finance.yahoo.com/table.csv?s=APPL&a=01&b=1&c=2010&d=01&e=01&f=2011&g=d&ignore=.csv")

a = numpy.genfromtxt(f1, delimiter=',', skip_header=0, names=True);
b = numpy.genfromtxt(f2, delimiter=',', skip_header=0, names=True);

prs = scipy.stats.pearsonr(a['Open'], b['Open'])

print prs
0

2 Answers 2

2

The stock symbol for Apple is AAPL, not APPL.

Therefore, use:

http://ichart.finance.yahoo.com/table.csv?s=AAPL&a=01&b=1&c=2010&d=01&e=01&f=2011&g=d&ignore=.csv"
Sign up to request clarification or add additional context in comments.

Comments

0

There's something wrong with URL in f2. When I check in my browser: http://ichart.finance.yahoo.com/table.csv?s=APPL&a=01&b=1&c=2010&d=01&e=01&f=2011&g=d&ignore=.csv

I get: Sorry, the page you requested was not found. So you'll get a 404 error in this line

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.