I wrote this code exacty the same from the tutorial
from urllib import request

goog_url = 'http://real-chart.finance.yahoo.com/table.csv?s=GOLD&d=8&e=18&f=2015&g=d&a=6&b=30&c=2002&ignore=.csv'

def download_stock_data(csv_url):
response = request.urlopen(csv_url)
csv = response.read()
csv_str = str(csv)
lines = csv_str.split("\\n")
dest_url = r'gold.csv'
fx = open(dest_url,'w')
for line in lines:
fx.write(line + "\n")


But i get this error

C:\Python34\python.exe "C:/Users/Parth/PycharmProjects/Py Projects/web.py"
Traceback (most recent call last):
File "C:\Python34\lib\urllib\request.py", line 1182, in do_open
h.request(req.get_method(), req.selector, req.data, headers)
File "C:\Python34\lib\http\client.py", line 1088, in request
self._send_request(method, url, body, headers)
File "C:\Python34\lib\http\client.py", line 1126, in _send_request
File "C:\Python34\lib\http\client.py", line 1084, in endheaders
File "C:\Python34\lib\http\client.py", line 922, in _send_output
File "C:\Python34\lib\http\client.py", line 857, in send
File "C:\Python34\lib\http\client.py", line 834, in connect
self.timeout, self.source_address)
File "C:\Python34\lib\socket.py", line 494, in create_connection
for res in getaddrinfo(host, port, 0, SOCK_STREAM):
File "C:\Python34\lib\socket.py", line 533, in getaddrinfo
for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11002] getaddrinfo failed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:/Users/Parth/PycharmProjects/Py Projects/web.py", line 17, in
File "C:/Users/Parth/PycharmProjects/Py Projects/web.py", line 7, in download_stock_data
response = request.urlopen(csv_url)
File "C:\Python34\lib\urllib\request.py", line 161, in urlopen
return opener.open(url, data, timeout)
File "C:\Python34\lib\urllib\request.py", line 463, in open
response = self._open(req, data)
File "C:\Python34\lib\urllib\request.py", line 481, in _open
'_open', req)
File "C:\Python34\lib\urllib\request.py", line 441, in _call_chain
result = func(*args)
File "C:\Python34\lib\urllib\request.py", line 1210, in http_open
return self.do_open(http.client.HTTPConnection, req)
File "C:\Python34\lib\urllib\request.py", line 1184, in do_open
raise URLError(err)

Process finished with exit code 1