Skip to content

SharmaVrishab/github-trending-repositories-tracker_v2

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

10 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿ“ˆ GitHub Trending Repositories Scraper

A Python script that fetches trending GitHub repositories created in the last 7 days using the GitHub OAuth Device Flow for secure authentication.

Python GitHub Issues

โœจ Features

  • ๐Ÿ” Secure Authentication: Uses OAuth Device Flow (no password required)
  • โญ Trending Repositories: Fetches repositories with highest star growth
  • ๐Ÿ“… Recent Focus: Filters repos created in the last 7 days
  • ๐ŸŽฏ Language Filtering: Optional filtering by programming language
  • ๐Ÿ“Š Rich Information: Displays repo name, stars, description, and URL
  • ๐Ÿš€ Easy Setup: Simple installation and configuration

๐Ÿš€ Quick Start

Prerequisites

  • Python 3.7 or higher
  • A GitHub account
  • Git (for cloning the repository)

Installation

  1. Clone the repository:

    git clone https://github.com/SharmaVrishab/github-trending-repositories-tracker_v2
    cd github-trending-scraper
  2. Create a virtual environment (recommended):

    # Linux/Mac
    python -m venv venv
    source venv/bin/activate
    
    # Windows
    python -m venv venv
    venv\Scripts\activate
  3. Install dependencies:

    pip install -r requirements.txt

โš™๏ธ Setup

1. Create GitHub OAuth App

  1. Go to GitHub Settings โ†’ Developer settings โ†’ OAuth Apps
  2. Click "New OAuth App"
  3. Fill in the application details:
    • Application name: GitHub Trending Scraper (or your preferred name)
    • Homepage URL: http://localhost
    • Authorization callback URL: http://localhost
  4. Click "Register application"
  5. Copy the Client ID from the app settings page

2. Configure Environment Variables

Option A: Environment Variable (Recommended)

# Linux/Mac
export GITHUB_CLIENT_ID="your_client_id_here"

# Windows Command Prompt
set GITHUB_CLIENT_ID=your_client_id_here

# Windows PowerShell
$env:GITHUB_CLIENT_ID="your_client_id_here"

Option B: Configuration File Create a config.env file in the project root:

GITHUB_CLIENT_ID=your_client_id_here

๐ŸŽฎ Usage

Basic Usage

Run the script to fetch trending repositories:

python trending_repos.py

First-Time Setup

  1. Run the script
  2. Follow the authentication flow:
    • A device code will be displayed
    • Visit the GitHub device activation URL
    • Enter the device code
    • Authorize the application
  3. The script will automatically fetch and display trending repositories

Sample Output

๐Ÿ” Authenticating with GitHub...
๐Ÿ“ฑ Please visit: https://github.com/login/device
๐Ÿ”‘ Enter code: ABCD-1234
โœ… Authentication successful!

๐Ÿ“ˆ Top Trending Repositories (Last 7 Days):

โญ 2,847 stars | awesome-ai-tools
   ๐Ÿ”— https://github.com/user/awesome-ai-tools
   ๐Ÿ“ A curated list of awesome AI tools and resources

โญ 1,923 stars | react-native-awesome
   ๐Ÿ”— https://github.com/user/react-native-awesome
   ๐Ÿ“ Collection of awesome React Native components

โญ 1,456 stars | python-data-viz
   ๐Ÿ”— https://github.com/user/python-data-viz
   ๐Ÿ“ Beautiful data visualization examples in Python

๐Ÿ› ๏ธ Configuration Options

Language Filtering

To filter repositories by programming language, modify the search query in trending_repos.py:

# Example: Only Python repositories
search_url = f"{BASE_URL}/search/repositories?q=created:>={seven_days_ago}+language:Python&sort=stars&order=desc"

# Example: Only JavaScript repositories  
search_url = f"{BASE_URL}/search/repositories?q=created:>={seven_days_ago}+language:JavaScript&sort=stars&order=desc"

Customize Results Count

Change the number of repositories displayed by modifying the loop in the script:

# Display top 10 repositories instead of 5
for i, repo in enumerate(repos[:10]):

๐Ÿ“ Project Structure

github-trending-scraper/
โ”‚
โ”œโ”€โ”€ trending_repos.py        # Main Python script
โ”œโ”€โ”€ README.md                # This file
โ”œโ”€โ”€ requirements.txt         # Python dependencies
โ”œโ”€โ”€ .gitignore              # Git ignore file
โ”œโ”€โ”€ config.env              # Environment variables (optional)

๐Ÿ”ง Dependencies

  • requests: HTTP library for API calls
  • python-dotenv (optional): Load environment variables from .env file

๐Ÿ› Troubleshooting

Common Issues

โŒ "Client ID not found"

  • Ensure you've set the GITHUB_CLIENT_ID environment variable
  • Double-check the Client ID from your GitHub OAuth App settings

โŒ "Authentication failed"

  • Make sure you're entering the device code correctly
  • Check that you've authorized the application in GitHub
  • Verify your internet connection

โŒ "API rate limit exceeded"

  • GitHub has API rate limits. Wait a few minutes before trying again
  • Authenticated requests have higher rate limits than unauthenticated ones

Getting Help

If you encounter issues:

  1. Check the Issues page
  2. Create a new issue with:
    • Error message
    • Python version
    • Operating system
    • Steps to reproduce

๐Ÿค Contributing

Contributions are welcome! Here's how you can help:

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Clone your fork
git clone https://github.com/yourusername/github-trending-scraper.git

# Create development branch
git checkout -b feature/your-feature-name

# Install development dependencies
pip install -r requirements.txt

๐Ÿ“‹ Future Enhancements

  • Export results to CSV/JSON
  • Web interface with Flask/FastAPI
  • Database storage for historical tracking
  • Email notifications for trending repos
  • Support for GitHub Enterprise
  • Advanced filtering options
  • Graphical charts and analytics

๐Ÿ™ Acknowledgments

  • GitHub API for providing the data
  • Requests library for HTTP handling
  • The open-source community for inspiration

๐Ÿ“ž Contact


โญ Found this helpful? Give it a star to show your support!

Happy coding! ๐Ÿš€

About

๐Ÿ”ฅ Discover trending GitHub repositories from the last 7 days, ranked by stars. Python script with OAuth authentication and modular design.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages