Skip to content

Commit d436596

Browse files
author
Panos
committed
get the todays stars
1 parent 961e069 commit d436596

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

github_trending/scraper.py

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,16 @@ def _extract_stars(self, article) -> str:
117117

118118
def _extract_stars_today(self, article) -> str:
119119
"""Extract stars gained today."""
120-
stars_today_element = article.find('span', class_='d-inline-block')
121-
if stars_today_element and "stars today" in stars_today_element.get_text():
122-
stars_today_match = re.search(r'(\d+(?:,\d+)*)', stars_today_element.get_text())
123-
if stars_today_match:
124-
return stars_today_match.group(1).replace(',', '')
120+
# Look for the span that contains "stars today" text
121+
# The element has classes like "d-inline-block float-sm-right"
122+
spans = article.find_all('span')
123+
for span in spans:
124+
span_text = span.get_text().strip()
125+
if "stars today" in span_text:
126+
# Extract the number from text like "957 stars today"
127+
stars_today_match = re.search(r'(\d+(?:,\d+)*)\s+stars today', span_text)
128+
if stars_today_match:
129+
return stars_today_match.group(1).replace(',', '')
125130
return "0"
126131

127132
def get_readme(self, repo_url: str) -> str:

0 commit comments

Comments
 (0)