<jupyter_start><jupyter_text>Webscrapping Real estate data from Banglore city<jupyter_code># Importing Libraries
from bs4 import BeautifulSoup
import requests
from csv import writer
url = "https://www.magicbricks.com/property-for-sale/residential-real-estate?bedroom=2,3&proptype=Multistorey-Apartment,Builder-Floor-Apartment,Penthouse,Studio-Apartment,Residential-House,Villa&cityName=Bangalore"
page = requests.get(url)
print(page)    # 200 means response successful
soup = BeautifulSoup(page.content, 'html.parser')
lists = soup.find_all('div',class_="mb-srp__list")

with open('housing.csv','w', encoding='utf8', newline='') as f:
    thewriter = writer(f)
    header = ['Builder', 'Name','Posted date','Area','Move in', 'Location','Price','sqft']
    thewriter.writerow(header)
    for list in lists:
        builder =list.find('div', class_="mb-srp__card__ads--name").text
        title = list.find('a', class_="mb-srp__card__society--name").text
        posted_date = list.find('div', class_="mb-srp__card__photo__fig--post").text
        Area = card.find('div',class_="mb-srp__card__summary--value").text
        move_in =list.find('div',class_="mb-srp__card__summary--value").text
        location = list.find('h2',class_="mb-srp__card--title").text
        price = list.find('div',class_="mb-srp__card__price--amount").text
        sqft = list.find('div',class_="mb-srp__card__price--size").text
        
        info = [builder,title, posted_date,Area, move_in, location, price, sqft]
        thewriter.writerow(info)
cards = soup.find_all('div', class_="mb-srp__card__summary__list")
values = soup.find_all('div', class_="mb-srp__card__summary--value")
values
for card in cards:
    values = card.find_all('div',class_="mb-srp__card__summary--value")
    for val in values:
        print(val.text)<jupyter_output>1299 sqft
Poss. by Mar '25
New Property
Unfurnished
1 Open
2
1563 sqft
Ready to Move
4 out of 4
New Property
Unfurnished
1 Covered
4
1361 sqft
Poss. by Dec '23
New Property
Unfurnished
1 Covered
2
1125 sqft
Ready to Move
New Property
Unfurnished
1 Covered
2
1525 sqft
Poss. by Jun '22
New Property
Unfurnished
3
1570 sqft
Ready to Move
New Property
Unfurnished
2
1407 sqft
Poss. by Mar '22
New Property
Unfurnished
1 Covered
2
1729 sqft
Ready to Move
New Property
Unfurnished
1 Covered
3
1812 sqft
Ready to Move
New Property
Unfurnished
1 Open
3
1115 sqft
Poss. by Dec '22
New Property
Semi-Furnished
1 Covered
2
1525 sqft
Poss. by Dec '22
New Property
Unfurnished
1 Covered
2
1718 sqft
Poss. by Apr '22
New Property
Unfurnished
1 Covered
3
1500 sqft
Poss. by Sep '23
New Property
Unfurnished
1 Covered
2
1112 sqft
Ready to Move
New Property
Unfurnished
1 Covered
2
2015 sqft
Ready to Move
New Property
Unfurnished
1 Covered
3
1140 sqft
Poss. by Mar '23
New Property
Semi-Furnished
2
1317 sqft
Ready [...]
{'fraction_non_alphanumeric': 0.1088339222614841, 'fraction_numerical': 0.044169611307420496, 'mean_word_length': 4.518518518518518, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 1, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '119781', 'license': 'MIT', 'n_tokens_mistral': 1084, 'n_tokens_neox': 1014, 'n_words': 282, 'path': 'Webscrapping_Real_estate.ipynb', 'repo_name': 'sjanwalkar/House-price-prediction', 'size': '2830'}