-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1_bs4.py
More file actions
40 lines (31 loc) · 1.01 KB
/
Copy path1_bs4.py
File metadata and controls
40 lines (31 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
from bs4 import BeautifulSoup
import os
import json
path = f"/Users/manishpargai/Documents/scrap/Cafes Dharamshala"
dir_list = os.listdir(path)
change_list = []
cafes_data_list =[]
for i in range(len(dir_list)):
change= dir_list[i].replace(".html","").replace(".", "").replace("icloud", "")
cafes_data = {
"cafename": change,
"userId": [{"$oid": "67c9497b6a31d6241c359b93"}],
"reviews": [],
"createdAt": {"$date": "2024-12-24T13:12:56.774Z"},
"updatedAt": {"$date": "2025-02-03T09:16:07.371Z"},
"__v": 0,
"ambienceR": 0,
"foodR": 0,
"serviceR": 0,
"Av": 0,
"drinkR": 0
}
file_path = "cafes_list.json"
with open(file_path, "a", encoding="utf-8") as f:
f.write(json.dumps(cafes_data, ensure_ascii=False, indent=4) + ",\n")
print(cafes_data)
#with open("file.html", "r") as f:
#html = f.read()
#soup = BeautifulSoup(html, 'html.parser')
#print(soup.prettify())
#print(soup.title.text)