Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
software-project-WS25
Github Team
Commits
b6fd9515
Commit
b6fd9515
authored
Oct 28, 2025
by
Sridhar
Browse files
Data fetch code from github
parent
cbc3cded
Changes
1
Hide whitespace changes
Inline
Side-by-side
data_fetch.py
0 → 100644
View file @
b6fd9515
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
}
"
)
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment