-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.py
33 lines (25 loc) · 1 KB
/
main.py
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
from tools.functionalities import verifyDarazURL
from scrapers.daraz_scraper import Daraz
import asyncio
import time
if __name__ == "__main__":
async def main():
"""
Asynchronous function to execute the web scraping and data export process.
"""
start_time = time.time()
url = "https://www.daraz.com.np/air-conditioners/"
if verifyDarazURL(url):
print("Invalid link. Please enter a valid Daraz product category link.")
else:
daraz = Daraz(url)
mongo_db = True # Set this to False if you want to export to an Excel sheet
if mongo_db:
await daraz.export_to_mongo()
else:
await daraz.export_to_sheet()
total_time = round((time.time() - start_time), 2)
time_in_secs = round(total_time, 2)
time_in_mins = round((total_time / 60), 2)
print(f"Took {time_in_secs} seconds. | {time_in_mins} minutes.")
asyncio.run(main())