You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When running the scraper.py file, print(scraper.get_account(url)) in line 41 and 42 is never executed. I commented out the if statement and found an error under the __parse_place function in line 164 and 165.
Error:
File "googlemaps.py", line 165, in __parse_place
place['overall_rating'] = float(response.find('div', class_='gm2-display-2').text.replace(',', '.')) AttributeError: 'NoneType' object has no attribute 'text'
Tried using the required beautifulsoup, selenium version and tried different versions of chromedriver. That did not solve the issue. What could be the problem?
The text was updated successfully, but these errors were encountered:
The error is due to no text found in element 'div' with class 'gm2-display-2'. Did you verify if the link you scrape which causes this error actually has a RATING on the page.
If you are using over a lot of urls and do not care about a few of them, then you can catch the exception and continue as follows:
def __parse_place(self, response):
try:
place = {}
place['overall_rating'] = float(response.find('div', class_='gm2-display-2').text.replace(',', '.'))
place['n_reviews'] = int(response.find('div', class_='gm2-caption').text.replace('.', '').replace(',','').split(' ')[0])
except Exception as e:
# print something or pass
place['overall_rating'] = 'NOT_FOUND'
return place
When running the scraper.py file, print(scraper.get_account(url)) in line 41 and 42 is never executed. I commented out the if statement and found an error under the __parse_place function in line 164 and 165.
Error:
File "googlemaps.py", line 165, in __parse_place
place['overall_rating'] = float(response.find('div', class_='gm2-display-2').text.replace(',', '.')) AttributeError: 'NoneType' object has no attribute 'text'
Tried using the required beautifulsoup, selenium version and tried different versions of chromedriver. That did not solve the issue. What could be the problem?
The text was updated successfully, but these errors were encountered: