Looping through a list of urls for web scraping with BeautifulSoup
<p>I want to extract some information off websites with URLs of the form:
<a href="http://www.pedigreequery.com/american+pharoah" rel="nofollow">http://www.pedigreequery.com/american+pharoah</a>
where "american+pharoah" is the extension for one of many horse names.
I have a list of the horse names I'm searching for, I just need to figure out how to plug the names in after "<a href="http://www.pedigreequery.com/" rel="nofollow">http://www.pedigreequery.com/</a>"</p>

<p>This is what I currently have:</p>

<pre><code>import csv
allhorses = csv.reader(open('HORSES.csv') )
rows=list(allhorses)

import requests 
from bs4 import BeautifulSoup
for i in rows:      # Number of pages plus one 
    url = "http://www.pedigreequery.com/".format(i)
    r = requests.get(url)
    soup = BeautifulSoup(r.content)
    letters = soup.find_all("a", class_="horseName")
    print(letters)
</code></pre>

<p>When I print out the url it doesn't have the horse's name at the end, just the URL in quotes. the letters/print statement at the end are just to check if it's actually going to the website. 
This is how I've seen it done for looping URLs that change by numbers at the end- I haven't found advice on URLs that change by characters. </p>

<p>Thanks!</p>