For Loops in Python to read Long URL from shortened URL -


i'm python beginner , struggling loop function. if run code receive long url last entry. ideas? thanks

import urllib2 beautifulsoup import beautifulsoup  x in ('civ8jguveh','isrohi98ag','taz38yubob'):   shorturl = 'http://t.co/' + str(x) output = urllib2.urlopen(shorturl)  print output.url 

you reassigning variable every time before opening or printing url. need indent code assigning , printing output variable done within loop:

import urllib2 beautifulsoup import beautifulsoup  x in ('civ8jguveh','isrohi98ag','taz38yubob'):   shorturl = 'http://t.co/' + str(x)   output = urllib2.urlopen(shorturl)    print output.url 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -