-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproperties.py
More file actions
93 lines (73 loc) · 2.79 KB
/
Copy pathproperties.py
File metadata and controls
93 lines (73 loc) · 2.79 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
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
from bs4 import BeautifulSoup
import pandas as pd
import requests
url='https://www.makaan.com/greater-noida-residential-property/buy-property-in-greater-noida-city'
response= requests.get(url)
owner= []
in_BHK= []
total_size_in_sqft= []
prices= []
price_in_sq_ft= []
many_years_old= []
const_status_of_building= []
locality_ares= []
soup= BeautifulSoup(response.content, 'html')
print('------------------------------------------------------------------')
# Get builder
own= soup.find_all('div', attrs={'class': 'second-line'})
for woned_by in own:
owner.append(woned_by.text)
# print('Sell by :- ', woned_by.span.text)
# Get rooms
rooms= soup.find_all('div', attrs={'class': 'title-line'})
for room in rooms:
in_BHK.append(room.text)
# print('room set in BHK :- ',room.span.text)
# # Get prices
price= soup.find_all('div', attrs={'data-type': 'price-link'})
for price in price:
prices.append(price.text)
# print('Price of building :- ',price.text)
# # price for sq/ft
price_sq_ft= soup.find_all('td', attrs={ 'class': 'lbl rate'})
for area in price_sq_ft:
price_in_sq_ft.append(area.text)
# print('Price per sq/ft :- ',area.text)
# # Area in sq ft
total_sq_ft= soup.find_all('td', attrs={'class': 'size'})
for t_area in total_sq_ft:
total_size_in_sqft.append(t_area.text)
# print('Total area in sq ft :- ', t_area.text)
# Locality
locality=soup.find_all('span', attrs={'itemprop': 'addressLocality'})
for local_area in locality:
print('Local area :- ',local_area.text)
# # Years old
year_old= soup.find_all('li', attrs={'title': 'old'})
for old in year_old:
many_years_old.append(old.text)
# print('how many years old :- ', old.text)
# Construction Status
const_status= soup.find_all('td', attrs={'class': 'val'})
for build_status in const_status:
const_status_of_building.append(build_status.text)
# print('Construction Status :- ', const_status.text)
print('------------------------------------------------------------------')
# df= pd.DataFrame()
df = pd.DataFrame({'Owner':owner,'Rooms set':in_BHK, 'Price in sq ft':price_in_sq_ft, 'Total sq ft':total_size_in_sqft, 'Price':prices, 'Construction Status': const_status_of_building})
df.to_csv('Gr_noida_apartment.csv', index=False, encoding='utf-8')
# for multiple pages
base_url='https://www.makaan.com/greater-noida-residential-property/buy-property-in-greater-noida-city?page='
# https://www.makaan.com/greater-noida-residential-property/buy-property-in-greater-noida-city?page=4&_=1671800758514
owner1= []
for i in range(1, 11):
url= base_url+str(i)
# print(url)
mult_response= requests.get(url)
soup1= BeautifulSoup(mult_response.content, 'html')
# print(soup1)
# Get builder
own1= soup.find_all('div', attrs={'class': 'second-line'})
for woned_by in own1:
owner1.append(woned_by.text)
print(owner1)