Web Scraping Project With Source Code

hello, readers today's post is for all technical students are you guys learning web scraping and how to scrape any web using Python then you can check this post.


Here in this post we also add a mini web scraping Python project with source code this can help you to understand how to use beautifulsoup for web scraping using Python.


But before we start the project let me tell you what is web scraping.


 what is web scraping?

Web scraping is an automated process that lets you scrape data from any website in a structured format, for example, text, images, and other media.


In today's time, almost all companies are using data to prepare their business model.


Understand from example


If an e-commerce company wants to see which product is selling more in which area, then that company will use machine learning and for that company needs data.


  So from this point of view, you can see how important is the data for the company and what is the importance of web scraping in the modern world.


Web Scraping Projects

For this project, we will use the Website : 

 https://www.marketwatch.com/investing/stock/aapl


From this website, we will scrape Apple's share price, closing price, and day range.


Steps For Web Scraping Projects


Step 1: Import basic library : 


import requests

import BeautifulSoup

 

Step 2: Check The URL REquest

URL = ' https://www.marketwatch.com/investing/stock/aapl'


HTML = requests.get(url)


soupBeautifulSoup(HTML.text, 'lxml')


soup


Step 3: Scrap Current Apple Share Price

Price = soup.find('bg-quote', class_='value').text

price


scrape apple share price
scrape apple share price



Step 4: Scrap Closing Price

Clo_Price = soup.find( 'td' , class_='table__cell u-semi').text

Clo_Price


Scrap Closing Price
Scrap Closing Price



Step 5: Now Scrape Day Range :


In this process, we have to create a separate object for Day Range Data because the class which has been used in Day Range has been used with many tags.


Nested = soup.find('mw-rangebar' class_ = 'element element--range range--daily')

Nested


Now Scrape Day Range:


Lower Price = Nested.find_all('span' , calss_ = 'primary') 

Lower Price


Conclusion


Here in this post, we add a small web scraping projects that t can help you to understand the use of beautifulsoup and how can we scrap data from any website.

No comments:

Post a Comment

Popular Posts