title: Python - How to loop through a text file of urls and pass all the urls into a redirect handler
body: <p>I recently scraped a bunch of metadata using Python's BeautifulSoup Library. I saved all of the urls contained in that metadata to a .txt file. However, I need all of the redirect urls instead.  I'm able to do one url at a time with:</p>
  
  <pre><code>def get_redirect_url(url):
      opener = urllib2.build_opener(urllib2.HTTPRedirectHandler)
      request = opener.open(url)
      return request.url 
  print get_redirect_url("www.foo.com")
  print ""
  </code></pre>
  
  <p>I tried to pass the text file into a list and then pass that list as the argument and I get the following error: "TypeError: get_redirect_url() takes exactly 1 argument (11 given)"</p>
  
  <pre><code>def get_redirect_url(url):
      opener = urllib2.build_opener(urllib2.HTTPRedirectHandler)
      request = opener.open(url)
      return request.url 
  with open ('openCRS_url.txt', 'r') as myFile:
      data = [line.strip() for line in myFile]
  print get_redirect_url(*data)
  print ""
  </code></pre>
  
  <p>Is there a way that I can pass either the text file or the list representation of the data from that text file as the parameter of a function, loop through the file, and extract all the redirect urls?  Thank you all.</p>