python - URL Redirect from text file -
i'm still pretty new scripting. i'm trying figure out way output list of url after redirect has occurred. have 800 sites in text file want test redirect using python script , output final redirect file (on it's own line). possible?
with file open, can't figure out how create urllib2.urlopen() read line in text file. seems require url? maybe there module or else should using instead?
please help.
thanks!
i'd utilize requests library:
import requests open('urls.txt') url_file: url in url_file: resp = requests.get(url.strip()) print resp.url
python
No comments:
Post a Comment