Trouble finding function for Social-accounts #3273
Replies: 2 comments
-
For gathering twitter links (if stated in the user's GitHub profile), you can use the following API :
The returned JSON response will have a key named : import urllib.request
import json
with urllib.request.urlopen("https://api.github.com/users/KaranNegi20feb") as resp:
if resp.status == 200:
data = json.loads(resp.read().decode('utf-8'))
url = r"https://x.com/" + data["twitter_username"] # url == https://x.com/KaranNegi20feb
Hope this helps ✌️ |
Beta Was this translation helpful? Give feedback.
-
Thanks shubham 👍👍
…On Wed, Apr 16, 2025, 5:22 PM Shubham ***@***.***> wrote:
*For gathering twitter links* (if stated in the user's GitHub profile),
you can use the following API :
https://api.github.com/users/{user}
The returned JSON response will have a key named : twitter_username that
you can read for that specific {user}. And then prepend https://x.com/ to
it. For example:
import urllib.requestimport json
with urllib.request.urlopen("https://api.github.com/users/KaranNegi20feb") as resp:
if resp.status == 200:
data = json.loads(resp.read().decode('utf-8'))
url = r"https://x.com/" + data["twitter_username"] # url == https://x.com/KaranNegi20feb
NOTE 1: This approach is not foolproof (can result in low recall, as some
Twitter (or X) handles will be missed as the API sometimes puts it under
different key names).
NOTE 2: For hyperlinks of other social media accounts, I guess you can
build a web-scraper <https://en.wikipedia.org/wiki/Web_scraping> using
BeautifulSoup <https://pypi.org/project/beautifulsoup4/> and requests
<https://pypi.org/project/requests/>. This is quite a bit tedious and
hacky, so I would wait on that end for others to pitch in with better
alternatives.
Hope this helps ✌️
—
Reply to this email directly, view it on GitHub
<#3273 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/BCBNM6SFOHF54I6W3RLEZ2L2ZY77JAVCNFSM6AAAAABZ64YQKCVHI2DSMVQWIX3LMV43URDJONRXK43TNFXW4Q3PNVWWK3TUHMYTEOBVGM4DENY>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hey community,
I just had a doubt that does PyGithub has any function similar get_users, for the social accounts end point of like below is an example:
https://api.github.com/users/KaranNegi20Feb/social_accounts
I want to access this data, how can i using PyGithub.
[
{
"provider": "twitter",
"url": "https://x.com/KaranNegi20feb"
}
]
Beta Was this translation helpful? Give feedback.
All reactions