我正在尝试通过从网址中检索JSON然后通过美丽的汤运行来收集某些信息
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'对象没有属性'content'
我一直在编码和解码,试图解决问题之后的问题,是否有更简单的方法从谷歌api结果中检索标签信息?我做了一件可怕的事吗?