Last active
December 29, 2020 20:09
-
-
Save iamaziz/24072d0e44e9da38fb33eb2397fc21f5 to your computer and use it in GitHub Desktop.
Scrape the stars count of a GitHub repo (beautifulSoup)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from bs4 import BeautifulSoup as bs | |
import requests | |
def stars_count(url): | |
html = requests.get(url).text | |
soup = bs(html, 'lxml') | |
stars_class = "social-count js-social-count" | |
stars = soup.find('a', class_=stars_class).text.strip() | |
return stars | |
repo = 'https://github.com/TensorFlow/TensorFlow' | |
print(stars_count(repo)) | |
# out: 43,939 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment