Assignment


1️⃣ HTTP Requests with requests (5 Assignments)

Assignment 1: Install requests and Fetch a Web Page

🔹 Task: Install requests and make a simple GET request. 🔹 Example Command:

pip install requests

🔹 Example Snippet:

import requests

response = requests.get("https://www.example.com")
print(response.text)

Assignment 2: Check Response Status Code

🔹 Task: Fetch a URL and print its status code. 🔹 Example Snippet:

response = requests.get("https://www.example.com")
print(f"Status Code: {response.status_code}")

Assignment 3: Send a POST Request with Data

🔹 Task: Make a POST request with form data. 🔹 Example Snippet:


Assignment 4: Handle HTTP Headers in a Request

🔹 Task: Send a request with custom headers. 🔹 Example Snippet:


Assignment 5: Handle API Responses (JSON Format)

🔹 Task: Fetch and parse JSON data from an API. 🔹 Example Snippet:


2️⃣ Parsing HTML with BeautifulSoup (5 Assignments)

Assignment 6: Install BeautifulSoup and Parse an HTML Page

🔹 Task: Install beautifulsoup4 and parse a simple HTML page. 🔹 Example Command:

🔹 Example Snippet:


🔹 Task: Fetch and extract all anchor (<a>) tags. 🔹 Example Snippet:


Assignment 8: Extract Text from Specific HTML Elements

🔹 Task: Extract all paragraph (<p>) texts from a page. 🔹 Example Snippet:


Assignment 9: Extract Data from Tables

🔹 Task: Scrape table data from an HTML page. 🔹 Example Snippet:


Assignment 10: Extract Images from a Web Page

🔹 Task: Find all image (<img>) sources. 🔹 Example Snippet:


3️⃣ Extracting Data from Web Pages (5 Assignments)

Assignment 11: Web Scraping with Pagination

🔹 Task: Scrape data from multiple pages. 🔹 Example Snippet:


Assignment 12: Scrape Job Listings from a Website

🔹 Task: Extract job titles from a job portal. 🔹 Example Snippet:


Assignment 13: Extract Product Prices from an E-commerce Site

🔹 Task: Fetch product names and prices. 🔹 Example Snippet:


Assignment 14: Download Images from a Website

🔹 Task: Download and save images. 🔹 Example Snippet:


Assignment 15: Scrape Weather Data from a Website

🔹 Task: Extract temperature from a weather site. 🔹 Example Snippet:


4️⃣ Regex (re Module) for Pattern Matching (5 Assignments)

Assignment 16: Validate Email Addresses with Regex

🔹 Task: Check if an email is valid. 🔹 Example Snippet:


Assignment 17: Extract All URLs from Text

🔹 Task: Find all links in a text. 🔹 Example Snippet:


Assignment 18: Find Phone Numbers in a Text

🔹 Task: Extract phone numbers using regex. 🔹 Example Snippet:


Assignment 19: Extract Dates from a Text

🔹 Task: Find all dates in a text. 🔹 Example Snippet:


Assignment 20: Remove HTML Tags from Text

🔹 Task: Use regex to strip HTML tags. 🔹 Example Snippet:


Last updated