A simple web scraping project using Python's requests
and BeautifulSoup
to extract information from a website like Times of India.
- Python: Core programming language for backend logic.
- Requests: For making HTTP requests and fetching the HTML code.
- BeautifulSoup: For parsing and navigating through HTML data.
This project demonstrates how to scrape web pages using the requests
module to fetch HTML and BeautifulSoup
to parse and extract meaningful data. The code extracts various HTML elements like:
- Paragraphs (
<p>
) - Headings (
<h1>
,<h2>
) - Links (
<a>
) - Images (
<img>
)
It also shows how to extract specific content based on CSS class names or HTML IDs.
- Fetch HTML code from a website.
- Parse and pretty-print the HTML structure.
- Extract elements like title, paragraphs, links, and images.
- Find specific content by class names and IDs.
- Extract all links and image URLs on the page.
To install the required dependencies, follow these steps:
- Clone the repository:
https://github.com/Abhimanyu-Gaurav/WebScraping
- Navigate to the project directory:
cd WebScraping
- Install the dependencies:
pip install -r requirements.txt
-
Modify the
url
variable in the script to the website you want to scrape. -
Run the script:
python main.py
-
The script will print extracted information such as:
- Page title
- Paragraph text
- All links and images
- This project is licensed under the MIT License - see the License file for details.