for tag in tags:
Ulist1.append(tag.get('href', None))
if len(Ulist1) > 2:
print Ulist1[2]
html = urllib.urlopen(Ulist1[2]).read()
soup = BeautifulSoup(html)
tags = soup('a')
Ulist2 = list ()
for tag in tags:
Ulist2.append(tag.get('href', None))
if len(Ulist2) > 2:
print Ulist2[2]
html = urllib.urlopen(Ulist2[2]).read()
soup = BeautifulSoup(html)
tags = soup('a')
Ulist3 = list ()
for tag in tags:
Ulist3.append(tag.get('href', None))
if len(Ulist3) > 2:
print Ulist3[2]
html = urllib.urlopen(Ulist3[2]).read()
soup = BeautifulSoup(html)
tags = soup('a')
Ulist4 = list ()
for tag in tags:
Ulist4.append(tag.get('href', None))
this is using beautiful soup to parse HTML and find the link at position 3 (the first name is 1). Follow that link. Repeat this process 4 times. Is there a more efficient way of doing this instead of using nested loops?