Kundai2020 / Webscraping

Real Estate Webscraping using residential.com website
0 stars 0 forks source link

Webscraping using residential.com website⛪🏛👩‍💻1️⃣ #1

Open Kundai2020 opened 4 months ago

Kundai2020 commented 4 months ago

Introduction: Web scraping, also known as web harvesting or web data extraction, is the process of extracting information from websites. It involves accessing and collecting data directly from web pages, often using automated bots or web crawlers. The importance of web scraping lies in several key areas: Data Collection and Analysis: Web scraping enables the extraction of vast amounts of data from the internet, which can be used for various purposes such as market research, competitor analysis, and trend monitoring. Businesses can gather data on customer reviews, pricing information, product details, and other relevant information to make informed decisions. Competitive Intelligence: Organizations can use web scraping to monitor competitors' websites and extract data on their products, prices, promotions, and customer reviews. This helps in staying competitive and adapting strategies accordingly. Price Monitoring and Comparison: E-commerce businesses can use web scraping to monitor prices of products on different websites. This allows them to adjust their own pricing strategies in real-time to stay competitive in the market. Lead Generation: Web scraping can be employed to extract contact information, email addresses, and other details from websites. This data can be useful for generating leads, building marketing databases, and reaching out to potential customers. Market Research: Researchers and businesses can use web scraping to collect data on market trends, consumer behavior, and other relevant information. This helps in making data-driven decisions and staying informed about changes in the market. Content Aggregation: Web scraping is often used to aggregate content from various sources to create comprehensive databases or feeds. News aggregators, job boards, and real estate listing websites are examples of platforms that benefit from web scraping. Monitoring and Alerts: Web scraping allows for the automated monitoring of specific websites or pages for changes. This can be useful for tracking news, updates, or any alterations in data that are of interest. Language Processing and Machine Learning: Extracted data from the web can be used as a valuable resource for training machine learning models and natural language processing algorithms. This is particularly useful for sentiment analysis, chatbots, and other applications. While web scraping offers numerous advantages, it's important to note that ethical considerations and legal compliance must be taken into account. Some websites may have terms of service that explicitly prohibit scraping, and scraping data in violation of these terms may lead to legal consequences. Therefore, it's crucial to respect the rules and policies of the websites being scraped and ensure that the process is conducted ethically and responsibly. Aim: Build a book Web scraping code and save the data into a CSV/Xlxs file. Objectives: 1:Requesting the URL of the website using the requests library 2: Naming columns into required data-(Title,Link,Prices,Stock) 3: Using BeautifulSoup Library to scrap the data 4: Using Pandas to structure the data into CSV/Xlxs file IDE: Jupyrer Notebook Programming Language: Python

Kundai2020 commented 4 months ago

`import requests from bs4 import BeautifulSoup import pandas as pd Rental=[] current_page=1 proceed=True while(proceed):

url=f'https://www.residential.com/homesearch/for_rent/CA/Los_Angeles?show_views_counter=1&show_days_on_market=0&page={current_page}&sort=-listed_date'
response=requests.get(url)
html=response.text
soup=BeautifulSoup(html,'html.parser')
if soup.title.text=='404 Not Found':
     proceed=False
else:
    accomodation=soup.find('div',{'class':'container_listingsList__cLFTb'})
    home=accomodation.find_all('a',{'class':'listing_listing__s6sYv'})

    for house in home:
        price=house.find('div',{'class':'listing_price__Btsti'}).text.strip()
        area=house.find('div',{'class':'listing_details__D3EEd'}).text.strip()
        adress=house.find('div',{'class':'listing_address__Xntl0'}).text.strip()
        name=[]
        try:
            n=house.find_all('div',{'class':'agent-source_name__iAwOO'})[0]
            name.append(n.text[13:].strip())
        except:
            name.append('Agent info not found')
current_page+=1

Rental.append([name,adress,area,price])
df=pd.DataFrame(Rental,columns=['Name','Adress','Residential information','Price']) df.to_csv('C:/Users/DELL/Desktop/Python Projects/Python/Codes/houses.csv',index=False) [Uploading Rental Houses.csv…]() `