Skip to content

Commit 692522d

Browse files
Merge branch 'devmalik7:main' into main
2 parents 8c02f79 + cff5167 commit 692522d

File tree

13 files changed

+1163
-0
lines changed

13 files changed

+1163
-0
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# News Headline Scraper (Python)
2+
3+
A simple Python script that fetches news headlines from various news outlets using their public RSS feeds and saves them to a JSOn file, no API keys are required in the process.
4+
---
5+
6+
## 🚀 Features
7+
- Saves headlines to JSON with timestamps.
8+
- Multiple trusted sources: BBC, Reuters, CNN, NYTimes, HackerNews
9+
- No API key needed (uses official RSS feeds)
10+
11+
---
12+
## Usage
13+
14+
python3 news_headline_scraper.py
15+
16+
Output:
17+
Fetching: BBC
18+
Fetching: Reuters
19+
Fetching: CNN
20+
Fetching: NYTimes
21+
Fetching: HackerNews
22+
Headlines saved to the file
23+
24+
## 🧰 Requirements
25+
26+
Install the dependencies using pip:
27+
```bash
28+
pip install feedparser
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
import json
2+
from datetime import datetime
3+
import feedparser
4+
import sys
5+
6+
def fetch_headlines(feed):
7+
headlines = {}
8+
for name, url in feed.items():
9+
print(f"Fetching: {name}")
10+
feed = feedparser.parse(url)
11+
# print("FEED", feed)
12+
temp_list=[]
13+
for entry in feed.entries:
14+
article = {
15+
"title": entry.title,
16+
"link": entry.link,
17+
"published": entry.get("published", None)
18+
}
19+
temp_list.append(article)
20+
headlines[name]= temp_list
21+
return headlines
22+
23+
24+
25+
def save_to_json(data, filename="news_headlines.json"):
26+
timestamp = datetime.now().isoformat()
27+
output = {"timestamp": timestamp, "sources": data}
28+
with open(filename, "w", encoding="utf-8") as f:
29+
json.dump(output, f, indent=4, ensure_ascii=False)
30+
print("Headlines saved to the file")
31+
32+
if __name__=="__main__":
33+
34+
feed={
35+
"BBC": "https://feeds.bbci.co.uk/news/rss.xml",
36+
"Reuters": "https://feeds.reuters.com/reuters/topNews",
37+
"CNN": "http://rss.cnn.com/rss/edition.rss",
38+
"NYTimes": "https://rss.nytimes.com/services/xml/rss/nyt/HomePage.xml",
39+
"HackerNews": "https://hnrss.org/frontpage"
40+
}
41+
42+
headlines=fetch_headlines(feed)
43+
save_to_json(headlines)

Python/News Headline Scraper/news_headlines.json

Lines changed: 649 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
feedparser
2+
json
3+
datetime
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import datetime
2+
import os
3+
import sys
4+
5+
try:
6+
import pyautogui
7+
USE_PYAUTOGUI = True
8+
except ImportError:
9+
import mss
10+
USE_PYAUTOGUI = False
11+
12+
def take_screenshot(save_dir="Screenshots"):
13+
# Create the folder if it doesn't exist
14+
if not os.path.exists(save_dir):
15+
os.makedirs(save_dir)
16+
17+
# Generate timestamped filename
18+
timestamp = datetime.datetime.now().strftime("%Y-%m-%d_%H-%M-%S")
19+
filename = f"screenshot_{timestamp}.png"
20+
filepath = os.path.join(save_dir, filename)
21+
22+
# Capture and save the screenshot
23+
if USE_PYAUTOGUI:
24+
screenshot = pyautogui.screenshot()
25+
screenshot.save(filepath)
26+
else:
27+
with mss.mss() as sct:
28+
sct.shot(output=filepath)
29+
30+
print(f" Screenshot saved as: {filepath}")
31+
32+
if __name__ == "__main__":
33+
take_screenshot()
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
# 📸 Screenshot Capture Tool
2+
3+
A simple Python tool that captures your **screen** and automatically saves it with a **timestamped filename**.
4+
This project is perfect for logging visual data, monitoring screen changes, or quickly taking snapshots.
5+
6+
---
7+
8+
## 📜 What the Script Does
9+
10+
- Captures a **full-screen screenshot** of your current display.
11+
- Automatically generates a **timestamped filename** (e.g., `screenshot_2025-10-11_22-05-30.png`).
12+
- Saves the screenshot in a folder called **Screenshots**, which is **automatically created** if it doesn’t exist.
13+
- Auto-detects Python version and uses the best compatible library (`pyautogui` for ≤3.12, `mss` for 3.13+).
14+
- Prints a success message showing where the file was saved.
15+
16+
---
17+
18+
## 🛠️ How to Run the Script
19+
20+
### **Prerequisites**
21+
Make sure you have **Python 3** installed.
22+
Install the required libraries:
23+
24+
```bash
25+
pip install pyautogui mss
26+
```

Python/face_detector/README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# Real-Time Face Detection with OpenCV Haar cascades
2+
3+
## Description
4+
This Python script captures video from a webcam and performs real-time face detection using OpenCV’s built-in Haar cascades.
5+
Key features include:
6+
- Detection of multiple faces per frame.
7+
- Smoothing of face positions using Exponential Moving Average (EMA) to reduce jitter.
8+
- Dynamic scaling of label text based on the detected face size.
9+
- Drawing bounding boxes around detected faces.
10+
- Display of FPS (Frames Per Second) to monitor processing speed.
11+
12+
All detection and display parameters are fully configurable via constants at the top of the script.
13+
This includes:
14+
- Camera source index (`CAMERA_SOURCE`)
15+
- Haar cascade parameters (`FD_SCALE_FACTOR`, `FD_MIN_NEIGHBORS`)
16+
- Face box appearance (`FACEBOX_COLOR`, `FACEBOX_THICKNESS`)
17+
- Label text settings (`TEXT_FONT`, `TEXT_DEFAULT_SIZE`, `TEXT_COEFF`, `TEXT_MARGIN`)
18+
- Smoothing parameters (`SMOOTH_ALPHA`, `SMOOTH_THRESHOLD`)
19+
- Matching distance for tracking faces (`MATCH_MAX_DISTANCE`)
20+
- FPS display settings (`FPS_COLOR`, `FPS_FONT_SCALE`, `FPS_POSITION`, `FPS_FONT`)
21+
22+
This makes it easy to tweak the behavior and appearance of the face detection system without modifying the core logic.
23+
24+
## Installation
25+
1. Make sure you have Python 3.10 or higher installed.
26+
2. Clone or download this repository.
27+
3. Install required dependencies using the `requirements.txt` file:
28+
```bash
29+
pip install -r requirements.txt
30+
````
31+
32+
## How to Run
33+
34+
1. Connect a webcam or ensure your camera source is available.
35+
2. Run the script:
36+
37+
```bash
38+
python main.py
39+
```
40+
3. A window will open showing the live video feed. Detected faces will have rectangles and labels.
41+
4. Press `q` to exit the video window.

0 commit comments

Comments
 (0)