File size: 1,375 Bytes
e79fbb1
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
41
42
43
def location_all(location,inside_location):
    import requests
    from bs4 import BeautifulSoup
    from Main_function_For_location import main

    
    location =location.replace(" ", "").lower()
    inside_location = inside_location.replace(" ", "-").lower()

    url = f"https://www.eateasy.ae/{location}/{inside_location}-restaurants"

    payload = {}
    files = {}
    headers = {
        'Cookie': 'eateasy-ae-website=lai3mvcb9hd99nnivbt0pn68ibfjsd6g',
        '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'
    }

    response = requests.post(url, headers=headers, data=payload, files=files)
    hrefs = []
    i = 1

    if response.status_code == 200:
        soup = BeautifulSoup(response.text, 'html.parser')
    
        links = soup.find_all('a', class_='eateasy-restaurant-box-inner')
        for link in links:
            href = link.get('href')
            if href:
                hrefs.append(href)
        print(f"Found {len(href)} Links")
        if hrefs:
            for href in hrefs:
                print(href)
                main(href,location,inside_location)
                i = i+1
                if i == 21:
                    break
        print(" DONE ") 

    else:
        print(f"Failed to retrieve the page. Status code: {response.status_code}")