This code allows you to scrape relevant information from a Github user's profile and analyze it using the GPT-4 API to suggest real open-source projects they could contribute to. Let's dive into how it works!
The scrape_github_data
function takes in a Github username as an argument and returns a dictionary with the following information:
username
: the Github usernamerepositories
: a list of repository names the user has createdcontributions
: a list of repository names the user has contributed todescription
: a short description of the user's profile
This information is obtained by sending a GET request to the Github API and parsing the response with BeautifulSoup.
The analyze_github_profile
function takes in a dictionary of the user's Github profile information and returns a list of real open-source projects the user could contribute to.
This function utilizes the OpenAI API and provides context and specificity to the API using prompt engineering. The list of suggestions is generated using the OpenAI completion API.
The final output of the code is the list of suggested open-source projects, which is obtained by calling the scrape_github_data
and analyze_github_profile
functions and passing in the Github username as an argument.
- Install the required libraries:
requests
,openai
, andbs4
. - Set up authentication with the OpenAI API by setting
openai.api_key
to your API key. - Call the
scrape_github_data
function with the Github username you want to scrape as an argument. - Call the
analyze_github_profile
function with the returned data from step 3 as the argument. - The function will return a list of suggested open-source projects for the user.
Example usage:
github_profile = scrape_github_data("yagcioglutoprak")
suggestions = analyze_github_profile(github_profile)
print(suggestions)
### Have fun scraping and analyzing Github profiles!