I have a list of URLs stored in a variable href
. When I pass it through the below function, the only returned recipe_links come from the first URL in href
. Are there any glaring errors with my code? I'm not sure why it wouldn't loop through all 20 URLs I have stored in href
. The returned results that I get for the first URL in href
are retrieved as expected, but I can't get the loop to the next URL.
def first_page_links(link):
recipe_links = []
recipe_html = []
for x in link:
page_request = requests.get(x)
recipe_html.append(html.fromstring(page_request.text))
print recipe_html
for x in recipe_html:
recipe_links.append(x.xpath('//*[@id="content"]/ul/li/a/@href'))
return recipe_links