2013-03-14 70 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()