2013-03-14 46 views
0
arg = urllib2.urlopen(argv[1]).read() 
soup = BeautifulSoup(arg) 
a_tags = soup.find_all('a') #so this stores a list with all the <a href="" /a> tags 

,我需要只有那些沒有鏈接到同一頁(不含在HREF符號#)卸下<A HREF = 「#」 標記蟒

任何人PLS ....

回答

2

您可以將href屬性與某個功能匹配:

for a in soup.find_all('a', href=lambda value: value.startswith('#')): 
    a.extract()