Skip to content

Commit 0941df0

Browse files
Merge pull request #2528 from smty2018/scraping
web scraping property websites like MagicBricks
2 parents e352335 + 53cee2b commit 0941df0

File tree

2 files changed

+67
-0
lines changed

2 files changed

+67
-0
lines changed

WebScrapingPropertyWebsite/ReadMe.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Web Scraping Script for Property Information
2+
3+
Description:
4+
This Python script uses the `requests` and `BeautifulSoup` libraries to scrape property information from a
5+
real estate website. Web scraping property websites like MagicBricks for Flats for sale in Kolkata Page. Finds specific elements or data points within the HTML content of the webpage.
6+
The data points extracted include property prices, titles, carpet areas, property statuses, and property ages.
7+
8+
Requirements:
9+
- `requests` library (`pip install requests`)
10+
- `beautifulsoup4` library (`pip install beautifulsoup4`)
11+
12+
Output:
13+
14+
https://github.com/avinashkranjan/Amazing-Python-Scripts/assets/74114936/cf2a7482-9755-4914-ad5b-8f52dcb88fdc
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import requests
2+
from bs4 import BeautifulSoup
3+
4+
response=requests.get("https://www.magicbricks.com/flats-in-kolkata-for-sale-pppfs")
5+
print(response.status_code)
6+
7+
8+
soup=BeautifulSoup(response.content,"html.parser")
9+
#print(soup.prettify())
10+
11+
first_anchor_tag = soup.find("a")
12+
#print(first_anchor_tag.prettify())
13+
14+
all=soup.find_all("div")
15+
#print(all)
16+
17+
parent=soup.find_parent("a")
18+
#print(parent)
19+
20+
siblings=soup.find_next_siblings("a")
21+
#print(siblings)
22+
23+
card=soup.find("div",attrs={"class":"mb-srp__list"})
24+
print("\n",card)
25+
26+
price=soup.find_all("div",attrs={"class":"mb-srp__card__price"})
27+
for i in price:
28+
print("\n", i.text)
29+
30+
price1=card.find("div",attrs={"class":"mb-srp__card__price--amount"})
31+
print("\n",price1.text)
32+
33+
title=soup.find_all("h2",attrs={"class":"mb-srp__card--title"})
34+
35+
for j in title:
36+
print("\n", j.text)
37+
38+
carpet_area=card.find("div",attrs={"class":"mb-srp__card__summary--value"})
39+
print("\n", carpet_area.text)
40+
41+
42+
43+
status= card.find("span", attrs={"class": "mb-srp__card__summary--value"})
44+
overlooking = card.find("div", attrs={"class": "mb-srp__card__summary--value"})
45+
46+
print("\nstatus:", status.text if status else "Not specified")
47+
print("size:", overlooking.text if overlooking else "Not specified")
48+
49+
property_age = card.find("div", attrs={"class": "mb-srp__card__age"})
50+
51+
print("\nProperty Age:", property_age.text if property_age else "Not specified")
52+
53+

0 commit comments

Comments
 (0)