A Python script that fetches trending GitHub repositories created in the last 7 days using the GitHub OAuth Device Flow for secure authentication.
- ๐ 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
- Python 3.7 or higher
- A GitHub account
- Git (for cloning the repository)
-
Clone the repository:
git clone https://github.com/SharmaVrishab/github-trending-repositories-tracker_v2 cd github-trending-scraper -
Create a virtual environment (recommended):
# Linux/Mac python -m venv venv source venv/bin/activate # Windows python -m venv venv venv\Scripts\activate
-
Install dependencies:
pip install -r requirements.txt
- Go to GitHub Settings โ Developer settings โ OAuth Apps
- Click "New OAuth App"
- Fill in the application details:
- Application name:
GitHub Trending Scraper(or your preferred name) - Homepage URL:
http://localhost - Authorization callback URL:
http://localhost
- Application name:
- Click "Register application"
- Copy the Client ID from the app settings page
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_hereRun the script to fetch trending repositories:
python trending_repos.py- Run the script
- Follow the authentication flow:
- A device code will be displayed
- Visit the GitHub device activation URL
- Enter the device code
- Authorize the application
- The script will automatically fetch and display trending repositories
๐ 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
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"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]):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)
- requests: HTTP library for API calls
- python-dotenv (optional): Load environment variables from
.envfile
โ "Client ID not found"
- Ensure you've set the
GITHUB_CLIENT_IDenvironment 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
If you encounter issues:
- Check the Issues page
- Create a new issue with:
- Error message
- Python version
- Operating system
- Steps to reproduce
Contributions are welcome! Here's how you can help:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
# 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- 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
- GitHub API for providing the data
- Requests library for HTTP handling
- The open-source community for inspiration
- Author: Vrishab
- GitHub: (https://github.com/sharmavrishab)
- Project Link: (https://github.com/SharmaVrishab/github-trending-repositories-tracker_v2)
โญ Found this helpful? Give it a star to show your support!
Happy coding! ๐