html:
<li class="dropdown menu-large menu_index_link"><a href="/MainPage" title="A">A</a></li>
<li class="dropdown menu-large menu_index_link"><a href="/apple" title="1">1</a></li>
They have the same html format but I only need the second one, what should I do with this? Maybe use title to distinguish?
Code:
for item in soup.find_all(attrs={'class':'dropdown menu-large menu_index_link'}):
for link in item.find_all('a'):
href=link.get('href') #print out both of the link
Problem solved as below:
for item in soup.find_all(attrs={'class':'dropdown menu-large menu_index_link'}):
for link in item.find_all('a', {'title': "1"}):
href=link.get('href') #print out the link I want
item.find_all('a', {'title': "1"})?