我正在寻找BeautifulSoup来检测链接中的NoFollow/DoFollow。有什么简单的方法可以做到这一点吗?我正在寻找一个选项,将忽略大小写敏感,并与不同的方式放置rel=nofollow的工作。
我有这个,但它不工作:
if 'nofollow' in link:
print "Nofollow"
else:
print "Dofollow"编辑:实际上我想通了,下面是代码:
if link in soup.find_all(rel="nofollow"):
print "NoFollow"
else:
print "Dofollow"看起来它是工作的,我将测试它更多,并编辑,如果有例外的需要。
发布于 2015-09-12 16:01:11
links = soup.find_all(rel=True) # This will find all links which has an attribute named 'rel'
for link in links:
print link['rel'] # This will print the value of rel attribute while looping through the earlier found linkshttps://stackoverflow.com/questions/32535507
复制相似问题