[Tutor] Python3: looping through web address

Umed Saidov umed.saidov at gmail.com
Sun Jul 17 22:00:19 EDT 2016


Hello Tutor(s),

I want to create a loop that loops through a web address, changing only 
a part of that address with each loop. I can't seem to be able to get 
the code to do this. Below is the code with some explanation of what I 
am trying to do. The code seems to loop through the ticker symbol file 
ignoring the web address. Is there another way of doing the same thing?

import urllib.request, json
import csv
import pandas as pd
import itertools

ticker = []
ticker = pd.DataFrame(ticker)

#open a cvs file with 100+ stock tickers from S&P500. Save in a 
dataframe 'ticker'.
ticker =pd.read_csv('tickers.csv')

#Loop through ticker, changing the designated part of the web address. 
Download the data into 'response'

for t in ticker.itertuples():
     response += 
urllib.request.urlopen('https:websiteaddress/{ct}/financials'.format(ct=ticker))



More information about the Tutor mailing list