我试图通过从url检索JSON并通过BeautifulSoup运行来收集某些信息
from bs4 import BeautifulSoup as soup
from urllib.request import urlopen as uReq
import googlemaps
placeDetailsResult =
urllib.request.urlopen('https://maps.googleapis.com/maps/api/place/details/
json?
placeid=ChIJXSggtzAF1h0RXd_aMn0d16Q&cr=countryZA&lr=lang_en&key='+googleKey)
.read()
info = json.loads(placeDetailsResult.decode('utf-8'))
ghtml = info.content
gsoup = soup(ghtml, "lxml")
rawFormattedAddress = gsoup.find_all('span', attrs={'class':
'Formatted_Address'})
print(rawFormattedAddress)
我得到:
ghtml = info.content AttributeError: 'dict' object has no attribute 'content'
我一直在编码和解码,试图解决一个又一个问题,有没有更简单的方法从谷歌api结果中检索标签信息?我在做什么可怕的事吗
目前没有回答
相关问题 更多 >
编程相关推荐