I am trying to scrape the number of reviews of a place from google maps using python. For example the restaurant Pike's Landing (see google maps URL below) has 162 reviews. I want to pull this number in python.
URL: https://www.google.com/maps?cid=15423079754231040967
I am not vert well versed with HTML, but from some basic examples on the internet I wrote the following code, but what I get is a black variable after running this code. If you could let me know what am I dong wrong in this that would be much appreciated.
from urllib.request import urlopen
from bs4 import BeautifulSoup
quote_page ='https://www.google.com/maps?cid=15423079754231040967'
page = urlopen(quote_page)
soup = BeautifulSoup(page, 'html.parser')
price_box = soup.find_all('button',attrs={'class':'widget-pane-link'})
print(price_box.text)
Seleniumto control web browser which will load page and run JavaScript. Or you can try to find this info in some JavaScript code - directly in HTML or in external files*.js. JavaScript can also uses AJAX/XHR to load data from different url and you can try to use DevTool in Chrome/Firefox to find this url. Mostly XHR gets data as JSON string which you can easily convert to python dictionary using modulejson- furasurlopen()and open this file in web browser or text editor. - furas