title: Python Printing Multiple Items- Web Scraping with XPath
body: <p>I am very novice to Python and programming in general so please forgive my lack of insight. I  have managed to web-scrape some data with Xpath.</p>
  <pre><code>
  #Dependencies 
  from lxml import html
  import requests
  
  #URL 
  url = 'https://web.archive.org/web/20171004082203/https://www.yellowpages.com/houston-tx/air-conditioning-service-repair'
  
  #Use Requests to retrieve html 
  resp = requests.get(url) 
  
  #Create Tree from Request Response 
  tree = html.fromstring(resp.content) 
  
  #Create Tree element
  elements = tree.xpath('//*[starts-with(@id,&quot;lid-&quot;)]/div/div/div[2]/div[2]/div[2]/a[1]') 
  # Scrape for URL and split for just business url
  websites= (elements[0].attrib['href'].split(&quot;http://&quot;)[1])
  
  </code></pre>
  <p>The output of this code returns a single website url. However, I would like to print all the business urls to eventually put to a Pandas data frame.</p>
  <p>How can I retrieve elements[0],elements[1],elements[2]... in one variable or expression?</p>
  <p>I am sure there is an iterative function or list comprehension for this but I cannot wrap my brain around it. I'm thinking something like this:</p>
  <p>Can I create a function to iterate through the 'elements[0]' and return all my values?</p>
  <p>Any help is greatly appreciated, Thanks!</p>