File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change 6
6
start = 0
7
7
file_path = f'yelp-{ city } -clean.txt'
8
8
9
- while start < 60 :
9
+ while start < 990 :
10
10
print (start )
11
11
url = base_url .format (city , start )
12
12
response = requests .get (url )
19
19
for biz in businesses :
20
20
first_line = ""
21
21
second_line = ""
22
+ phone_number = ""
22
23
try :
23
24
title = biz .find ('a' , {'class' : 'biz-name' }).text
24
25
address = biz .find ('address' ).contents
25
26
# print(address)
26
- phone = biz .find ('span' , {'class' : 'biz-phone' }).text
27
+ phone = biz .find ('span' , {'class' : 'biz-phone' }).contents
27
28
region = biz .find ('span' , {'class' : 'neighborhood-str-list' }).contents
28
29
count += 1
29
30
for item in address :
36
37
first_line += item .getText () + " "
37
38
else :
38
39
second_line += item .strip (" \n \t \r " ) + " "
40
+ for item in phone :
41
+ if "br" in item :
42
+ phone_number += item .getText () + " "
43
+ else :
44
+ phone_number += item .strip (" \n \t \r " ) + " "
39
45
40
46
except Exception as e :
41
47
print (e )
46
52
phone = None
47
53
region = None
48
54
49
- detail = f"{ title } \n { second_line } \n { phone } \n "
55
+ detail = f"{ title } \n { second_line } \n { phone_number } \n "
50
56
print (detail )
51
57
52
58
try :
57
63
logs .close ()
58
64
59
65
start += 30
60
-
You can’t perform that action at this time.
0 commit comments