# GitHub Repository Scraper (`fresh_cliff/github-scraper`) Actor

This actor scrapes detailed information from GitHub repositories using reliable HTTP requests and HTML parsing. It extracts repository metadata including star counts, fork counts, topics/tags, license information, primary programming language, and last updated timestamps.

- **URL**: https://apify.com/fresh_cliff/github-scraper.md
- **Developed by:** [Brennan Crawford](https://apify.com/fresh_cliff) (community)
- **Categories:** Developer tools, Agents, Automation
- **Stats:** 58 total users, 1 monthly users, 100.0% runs succeeded, 2 bookmarks
- **User rating**: No ratings yet

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## GitHub Repository Scraper for Apify

A Python-based Apify actor that scrapes GitHub repository information using requests and BeautifulSoup.

### Features

- Extracts repository information including:
  - Full name (owner/repo)
  - Star count
  - Description
  - Primary programming language
  - Topics/tags
  - Last updated time
  - License information
  - Fork count
- Written in Python using requests and BeautifulSoup for reliable scraping
- Built for the Apify platform

### Files

- `apify_actor.py` - The main actor code for Apify deployment
- `requests_github_scraper.py` - Standalone GitHub scraper (for local testing)
- `INPUT_SCHEMA.json` - Input schema for the Apify actor
- `requirements.txt` - Python dependencies
- `package.json` - Actor metadata for Apify

### Local Testing

1. Install dependencies: `pip install -r requirements.txt`
2. Run the local version: `python requests_github_scraper.py`
3. Check results in the `apify_storage` directory

### Deploying to Apify

#### Prerequisites

1. [Create an Apify account](https://console.apify.com/sign-up) if you don't have one
2. Install the Apify CLI: `npm install -g apify-cli`
3. Log in to your Apify account: `apify login`

#### Deployment Steps

1. Initialize your project folder (if you haven't already):
   ```
   apify init github-scraper
   ```

2. Modify the `Dockerfile` to use Python:
   ```Dockerfile
   FROM apify/actor-python:3.9

   # Copy source code
   COPY . ./

   # Install dependencies
   RUN pip install --no-cache-dir -r requirements.txt

   # Define how to run the actor
   CMD ["python3", "apify_actor.py"]
   ```

3. Push your actor to Apify:
   ```
   apify push
   ```

4. After pushing, your actor will be available in the [Apify Console](https://console.apify.com/actors).

#### Running on Apify

1. Navigate to your actor in the Apify Console
2. Click on "Run" in the top-right corner
3. Enter the GitHub repository URLs you want to scrape in the Input form
4. Click "Run" to start the actor
5. Access the results in the "Dataset" tab once the run is complete

### Input Options

- `repoUrls` (required): Array of GitHub repository URLs to scrape
- `sleepBetweenRequests` (optional): Delay between requests in seconds (default: 3)

### Example Input

```json
{
  "repoUrls": [
    "https://github.com/microsoft/playwright",
    "https://github.com/facebook/react",
    "https://github.com/tensorflow/tensorflow"
  ],
  "sleepBetweenRequests": 5
}

```

### Output Format

The actor provides clean, well-structured data for each GitHub repository in the following format:

```json
{
  "url": "https://github.com/microsoft/playwright",
  "name": "playwright",
  "owner": "microsoft",
  "fullName": "microsoft/playwright",
  "description": "Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.",
  "stats": {
    "stars": "71.2k",
    "forks": "4k"
  },
  "language": "TypeScript",
  "topics": [
    "electron",
    "javascript",
    "testing",
    "firefox",
    "chrome",
    "automation",
    "web",
    "test",
    "chromium",
    "test-automation",
    "testing-tools",
    "webkit",
    "end-to-end-testing",
    "e2e-testing",
    "playwright"
  ],
  "lastUpdated": "2025-03-17T17:00:47Z",
  "license": "Apache-2.0 license"
}
```

#### Output Fields:

| Field | Type | Description |
|-------|------|-------------|
| `url` | String | The full URL of the GitHub repository |
| `name` | String | Repository name (without owner) |
| `owner` | String | Username or organization that owns the repository |
| `fullName` | String | Complete repository identifier (owner/name) |
| `description` | String | Repository description |
| `stats.stars` | String | Number of stars the repository has |
| `stats.forks` | String | Number of forks the repository has |
| `language` | String | Primary programming language |
| `topics` | Array | List of topics/tags associated with the repository |
| `lastUpdated` | String | ISO timestamp of the last update |
| `license` | String | Repository license information |

This structured output format makes it easy to:

- Display repository cards in your applications
- Create data visualizations
- Filter and sort repositories by various attributes
- Export to other data formats

# Actor input Schema

## `repoUrls` (type: `array`):

List of GitHub repository URLs to scrape

## `sleepBetweenRequests` (type: `integer`):

Random sleep interval between requests (in seconds) to avoid rate limiting

## Actor input object example

```json
{
  "repoUrls": [
    "https://github.com/microsoft/playwright",
    "https://github.com/apify/apify-js"
  ],
  "sleepBetweenRequests": 3
}
```

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "repoUrls": [
        "https://github.com/microsoft/playwright",
        "https://github.com/apify/apify-js"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("fresh_cliff/github-scraper").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "repoUrls": [
        "https://github.com/microsoft/playwright",
        "https://github.com/apify/apify-js",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("fresh_cliff/github-scraper").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "repoUrls": [
    "https://github.com/microsoft/playwright",
    "https://github.com/apify/apify-js"
  ]
}' |
apify call fresh_cliff/github-scraper --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,fresh_cliff/github-scraper"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/f3Y2U5nqOZBRJCTDi/builds/KszSzi8H76KL3eZRZ/openapi.json
