-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtest2.py
More file actions
18 lines (13 loc) · 943 Bytes
/
test2.py
File metadata and controls
18 lines (13 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import requests, csv, time, re
import numpy as np
from bs4 import BeautifulSoup as bs
URL = "https://www.yelp.ca/biz/bar-karaoke-lounge-toronto"
response = requests.get(URL)
page = (response.text)
soup = bs(page, 'html.parser')
#collect number of reviews in total
total_rev = soup.find('div', attrs={'class': 'lemon--div__373c0__1mboc arrange-unit__373c0__o3tjT border-color--default__373c0__3-ifU nowrap__373c0__35McF'}).string.split(' ')[0]
total_rev = int(total_rev)
print(total_rev)
#<p class="lemon--p__373c0__3Qnnj text__373c0__2U54h text-color--mid__373c0__27i5f text-align--left__373c0__1Uy60 text-size--large__373c0__1j9OF">105 reviews</p>
#<div class="lemon--div__373c0__1mboc arrange-unit__373c0__o3tjT border-color--default__373c0__3-ifU nowrap__373c0__35McF"><p class="lemon--p__373c0__3Qnnj text__373c0__2U54h text-color--mid__373c0__27i5f text-align--left__373c0__1Uy60 text-size--large__373c0__1j9OF">105 reviews</p></div>