So I am following this tutorial on Webscraping with Python. Anytime I run the code I come across this error
FileNotFoundError: [Errno 2] No such file or directory: './data/nyct/turnstile/turnstile_200314.txt'
I have a hunch it means the webscraper cannot access the file but when I inspect the HTML the file is present. Please help. Here is my code for reference:
import requests
import urllib.request
import time
from bs4 import BeautifulSoup
#Set URL you want to webscrape from
url = 'http://web.mta.info/developers/turnstile.html'
#Connect to URL
response = requests.get(url)
#Parse HTML and save to BeautifulSoup object
soup = BeautifulSoup(response.text,'html.parser')
#Loop to download whole dataset
linecount = 1 #var to track current line
for onetag in soup.findAll('a'):
if linecount>=36:
link = onetag['href']
downloadurl = 'http://web.mta.info/developers/'+link
urllib.request.urlretrieve(downloadurl,'./'+link[link.find('/turnsttile_')+1:])
time.sleep(3)#pause code so as to not get flagged as spammer
#increment for next line
linecount+=1