1 # 上行遍历 2 soup = BeautifulSoup(demo, ‘html.parser‘) 3 for parent in soup.a.parents: 4 if parent is None: 5 print(parent) 6 else: 7 print(parent.name)
标签:one none style bsp gpo nts else -- for
1 # 上行遍历 2 soup = BeautifulSoup(demo, ‘html.parser‘) 3 for parent in soup.a.parents: 4 if parent is None: 5 print(parent) 6 else: 7 print(parent.name)
标签:one none style bsp gpo nts else -- for
原文地址:https://www.cnblogs.com/jonm/p/8366147.html