-
Notifications
You must be signed in to change notification settings - Fork 0
/
old_ui.py
140 lines (86 loc) · 2.5 KB
/
old_ui.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Mar 29 07:12:52 2020
@author: sagar
"""
import collections
import pandas as pd
from multiprocessing import Pool
import threading
import requests
from bs4 import BeautifulSoup
import time
import argparse
import timeit
start_time = time.time()
import os
class Dictlist(dict):
def __setitem__(self, key, value):
try:
self[key]
except KeyError:
super(Dictlist, self).__setitem__(key, [])
self[key].append(value)
test = Dictlist()
test1 = str()
url = 'https://www.zomato.com/allahabad/sagar-ratna-tagore-town'
agent = {"User-Agent":'Chrome/61.0.3163.100'}
page = requests.get(url, headers=agent)
soup_loop=BeautifulSoup(page.content, 'lxml')
main = soup_loop.find("div",{"class":"res-info-left col-l-11"})
try:
test['address'] = main.find("div",{"class":"resinfo-icon"}).getText()
except:
test['address'] = ''
try:
cost_for_two = main.find("div",{"class":"res-info-detail"})
test['cost_for_2'] = cost_for_two.find("span",{"tabindex":"0"}).getText()
except:
test['cost_for_2'] = ''
try:
rating = main.find("div",{"class":"col-l-4 tac left"})
rating= rating.find("div",{"tabindex":"0"})['aria-label']
test['rating'] = rating
except:
rating=''
test['rating'] = ''
try:
reviews = main.find("div",{"class":"col-l-4 tac left"})
reviews = reviews.find("span",{"itemprop":"ratingCount"}).getText()
test['reviews'] = reviews
except:
reviews=''
test['reviews'] = ''
try:
cuisines = main.find("div",{"class":"res-info-cuisines clearfix"}).getText()
test['cuisines'] = cuisines
except:
cuisines=''
test['cuisines'] = ''
try:
fav = main.find("div",{"class":"fontsize13 ln18"}).getText()
fav = fav.replace("\n"," ").strip(' ')
test['fav'] = fav
except:
fav=''
test['fav'] = ''
test['url'] = str(url)
try:
lat =soup_loop.find("meta",{"property" : "place:location:latitude"})
test['lat'] = str(lat["content"])
except:
test['lat'] = ""
try:
lon =soup_loop.find("meta",{"property" : "place:location:longitude"})
test['lon'] = str(lon["content"])
except:
test['lon'] = ""
try:
fav =main.find("div",{"class" : "fontsize13 ln18"})
fav_loop = fav.find_all("span")
for i in fav_loop:
test1=str(test1+","+i.getText().strip("\n ,")).lstrip(",").lower()
test['fav'] = test1
except:
test['fav'] = ""