Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
aichecker
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Jan Eggers
aichecker
Commits
d29b9d08
Commit
d29b9d08
authored
4 months ago
by
Jan Eggers
Browse files
Options
Downloads
Patches
Plain Diff
Demo
parent
b2342c48
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
async_reader.py
+4
-2
4 additions, 2 deletions
async_reader.py
read_posts.py
+62
-0
62 additions, 0 deletions
read_posts.py
with
66 additions
and
2 deletions
main
.py
→
async_reader
.py
+
4
−
2
View file @
d29b9d08
import
json
# Define the global posts list
posts
=
[]
...
...
@@ -68,9 +66,13 @@ def on_message_handler(message):
def
main
():
client
.
start
(
on_message_handler
)
return
if
__name__
==
"
__main__
"
:
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
read_posts.py
0 → 100644
+
62
−
0
View file @
d29b9d08
import
json
import
pandas
as
pd
from
atproto
import
Client
,
models
def
fetch_user_posts
(
handle
:
str
,
limit
:
int
=
100
)
->
list
:
# Initialize the Bluesky client (unauthenticated)
client
=
Client
()
try
:
# Fetch the user ID from the handle
profile
=
client
.
get_profile
(
handle
)
user_id
=
profile
.
did
# Initialize an empty list to store posts
posts
=
[]
# Fetch timeline for the user (latest posts first)
cursor
=
None
while
len
(
posts
)
<
limit
:
feed
=
client
.
app
.
bsky
.
feed
.
get_author_feed
(
actor
=
user_id
,
limit
=
min
(
limit
-
len
(
posts
),
50
),
cursor
=
cursor
)
if
not
feed
.
posts
:
break
posts
.
extend
(
feed
.
posts
)
cursor
=
feed
.
cursor
return
posts
[:
limit
]
except
Exception
as
e
:
print
(
f
"
An error occurred:
{
e
}
"
)
return
[]
def
main
():
# Define the Bluesky handle and number of posts to fetch
handle
=
'
@lion-c.bsky.social
'
# Replace with the desired handle
limit
=
100
# Fetch the last 100 posts from the specified user
posts
=
fetch_user_posts
(
handle
,
limit
)
if
not
posts
:
print
(
"
No posts fetched. Please check the handle and try again.
"
)
return
# Convert posts to a DataFrame
post_data
=
[]
for
post
in
posts
:
post_data
.
append
({
'
uri
'
:
post
.
uri
,
'
cid
'
:
post
.
cid
,
'
text
'
:
post
.
record
.
text
,
'
created_at
'
:
post
.
record
.
createdAt
,
'
author
'
:
handle
# Assuming you know the author's handle, otherwise fetch it from post record
})
df
=
pd
.
DataFrame
(
post_data
)
# Print or save the DataFrame as needed
print
(
df
)
df
.
to_csv
(
'
user_posts.csv
'
,
index
=
False
)
# Save to CSV for example
if
__name__
==
"
__main__
"
:
main
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment