viraj commited on
Commit
ad7ab3e
·
1 Parent(s): 93ba4cd

Added one file

Browse files
Files changed (1) hide show
  1. location_fetch_function.py +42 -0
location_fetch_function.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ def location_all(location,inside_location):
2
+ import requests
3
+ from bs4 import BeautifulSoup
4
+ from Main_function_For_location import main
5
+
6
+
7
+ location =location.replace(" ", "").lower()
8
+ inside_location = inside_location.replace(" ", "-").lower()
9
+
10
+ url = f"https://www.eateasy.ae/{location}/{inside_location}-restaurants"
11
+
12
+ payload = {}
13
+ files = {}
14
+ headers = {
15
+ 'Cookie': 'eateasy-ae-website=lai3mvcb9hd99nnivbt0pn68ibfjsd6g',
16
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36'
17
+ }
18
+
19
+ response = requests.post(url, headers=headers, data=payload, files=files)
20
+ hrefs = []
21
+ i = 1
22
+
23
+ if response.status_code == 200:
24
+ soup = BeautifulSoup(response.text, 'html.parser')
25
+
26
+ links = soup.find_all('a', class_='eateasy-restaurant-box-inner')
27
+ for link in links:
28
+ href = link.get('href')
29
+ if href:
30
+ hrefs.append(href)
31
+ print(f"Found {len(href)} Links")
32
+ if hrefs:
33
+ for href in hrefs:
34
+ print(href)
35
+ main(href,location,inside_location)
36
+ i = i+1
37
+ if i == 21:
38
+ break
39
+ print(" DONE ")
40
+
41
+ else:
42
+ print(f"Failed to retrieve the page. Status code: {response.status_code}")