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
提交
取消