@@ -299,3 +299,59 @@ phone-number of the restaurant.
299
299
300
300
This time we will be looking for the ``` div ``` tag that has class ``` biz-listing-large ```
301
301
that contains the restaurant details.
302
+
303
+ In ``` writing_details.py ``` We have reused a lot of code from other files the only
304
+ difference is that we open a new file, fetch the title, address, and phone number
305
+ from respective classes and write it into the file.
306
+
307
+ ```
308
+ ...
309
+ city = "los+angeles"
310
+
311
+ ...
312
+ file_path = f'yelp-{city}.txt'
313
+
314
+ with open(file_path, 'w') as textFile:
315
+ soup = BeautifulSoup(response.text, 'html.parser')
316
+ businesses = soup.findAll('div', {'class': 'biz-listing-large'})
317
+ count = 0
318
+ for biz in businesses:
319
+ title = biz.find('a', {'class': 'biz-name'}).text
320
+ address = biz.find('address').text
321
+ phone = biz.find('span', {'class': 'biz-phone'}).text
322
+ detail = f"{title}\n{address}\n{phone}"
323
+ textFile.write(str(detail) + '\n\n')
324
+
325
+ ```
326
+
327
+ We edit the city value so that it neither conflicts with url and our file path name.
328
+
329
+ ** yelp_los+angeles.txt** is still doesn't has text in nice formatted way like we wanted
330
+ but in the next section will be working on it.
331
+
332
+ ```
333
+ AMF Beverly Lanes
334
+
335
+ 1201 W Beverly Blvd
336
+
337
+
338
+ (323) 728-9161
339
+
340
+
341
+ Maccheroni Republic
342
+
343
+ 332 S Broadway
344
+
345
+
346
+ (213) 346-9725
347
+
348
+
349
+ Home Restaurant - Los Feliz
350
+
351
+ 1760 Hillhurst Ave
352
+
353
+
354
+ (323) 669-0211
355
+
356
+ ...
357
+ ```
0 commit comments