如何使用python从具有ng if属性的div元素中刮取链接?
Div元素如下所示如何使用python从具有ng if属性的div元素中刮取链接?,python,web-scraping,Python,Web Scraping,Div元素如下所示 ==0美元以下是答案: linne = '''<a ng-if="!People.disableActions" class="Name" ng-click="!People.disableActions && People.searchByAddress($event, People.record.address, People.record.Title)"
==0美元
以下是答案:
linne = '''<a ng-if="!People.disableActions"
class="Name" ng-click="!People.disableActions &&
People.searchByAddress($event, People.record.address, People.record.Title)"
href="https://...">Anna Bros</a> ==$0'''
from bs4 import BeautifulSoup
soup = BeautifulSoup(linne, 'lxml')
ng_if_Att = [values["ng-if"] for values in soup.findAll("a")]
href_link = [values["href"] for values in soup.findAll("a")]
print "ng_if attr = {0}".format(ng_if_Att[0])
print "href_link attr = {0}".format(href_link[0])
你已经试过什么了?
#output:
ng_if attr = !People.disableActions
href_link attr = https://...