Skip to content

Commit 3c74d5c

Browse files
committed
scraping
1 parent c0b68a7 commit 3c74d5c

File tree

1 file changed

+53
-0
lines changed

1 file changed

+53
-0
lines changed
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)