Commit b6fd9515 authored by Sridhar's avatar Sridhar
Browse files

Data fetch code from github

parent cbc3cded
import requests
import json
import pandas as pd
# Repository details
owner = "EbookFoundation"
repo = "free-programming-books"
# GitHub API endpoint
url = f"https://api.github.com/repos/{owner}/{repo}/issues"
headers = {
"Accept": "application/vnd.github+json",
# "Authorization": "Bearer YOUR_GITHUB_TOKEN" # optional
}
# Fetch issues
response = requests.get(url, headers=headers)
if response.status_code == 200:
issues = response.json()
# Extract key fields from each issue
data = []
for issue in issues:
data.append({
"id": issue.get("id"),
"number": issue.get("number"),
"title": issue.get("title"),
"state": issue.get("state"),
"created_at": issue.get("created_at"),
"updated_at": issue.get("updated_at"),
"user_login": issue["user"]["login"] if "user" in issue and issue["user"] else None,
"comments": issue.get("comments"),
"html_url": issue.get("html_url")
})
# Convert to DataFrame
df = pd.DataFrame(data)
print(df.head())
df.to_excel("C://Users//Nandhini//OneDrive//Dokumen//github_data.xlsx")
else:
print(f"Failed to fetch issues: {response.status_code}")
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment