import requestsimport urllib2from bs4 import BeautifulSoupfrom pprint import pprintimport pandas as pdimport bs4url = 'https://www.namus.gov/MissingPersons/Case#/53061'page = urllib2.urlopen(url)soup = BeautifulSoup(page, 'html')#print(soup.prettify())findall = soup.find_all("a")for link in findall: pprint(link.get("ng-href"))当我运行代码时,我设置了一个元组而不是链接。我试过引用 href、src、ng-href 和 non work。当我真的需要将谷歌地图的链接作为字符串时,我只能拉取 subSection。#I get this: u'{{subSection.mapLink()}}'#when I really need this: #"http://www.google.com/maps/place/35.9467011,-84.03260329999999"我尝试抓取的实际字符串如下所示:<a ng-if="subSection.mapLink()" class="icon-text-link" ng-href="http://www.google.com/maps/place/35.9467011,-84.03260329999999" target="_blank" href="http://www.google.com/maps/place/35.9467011,-84.03260329999999"> <i class="icon-location-pin"></i><span>Map</span> </a>
添加回答
举报
0/150
提交
取消