File tree Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Expand file tree Collapse file tree 1 file changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -708,10 +708,31 @@ def ensure_db_shape(db):
708
708
709
709
710
710
def scrape_dependents (repo , verbose = False ):
711
+ from bs4 import BeautifulSoup
712
+ url = "https://github.com/{}/network/dependents" .format (repo )
713
+ response = requests .get (url )
714
+ soup = BeautifulSoup (response .content , "html.parser" )
715
+ # Navigate through Package toggle if present
716
+ options = soup .find_all ("a" , class_ = "select-menu-item" )
717
+ links = []
718
+ if len (options ) > 0 :
719
+ for link in options :
720
+ links .append (link ['href' ])
721
+ else :
722
+ links .append (f"{ repo } /network/dependents" )
723
+
724
+ if verbose :
725
+ print (links )
726
+
727
+ for link in links :
728
+ yield from _scrape_dependents (f"https://github.com/{ link } " , verbose = verbose )
729
+
730
+
731
+
732
+ def _scrape_dependents (url , verbose = False ):
711
733
# Optional dependency:
712
734
from bs4 import BeautifulSoup
713
735
714
- url = "https://github.com/{}/network/dependents" .format (repo )
715
736
while url :
716
737
if verbose :
717
738
print (url )
You can’t perform that action at this time.
0 commit comments