Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save HadiElnemr/cdd4743f035269dcd62f54034f4e3718 to your computer and use it in GitHub Desktop.
Save HadiElnemr/cdd4743f035269dcd62f54034f4e3718 to your computer and use it in GitHub Desktop.
Hadi's soln
#!usr/bin/python3
import requests, re, csv
from bs4 import BeautifulSoup as sp
main_url = "https://commits.top/egypt.html"
r = requests.get(main_url)
soup = sp(r.content, 'html.parser')
table = soup.findAll('td')
gucians = []
# print(table)
with open('test1.csv','w' , newline='') as file:
writer = csv.writer(file)
for i in range(257*4):
if i%4==1:
try:
row = table[i].contents
username = row[0].text
prof = 'https://github.com/' + username
r = requests.get(prof)
soup = sp(r.content, 'html.parser')
name_tag = soup.find('span', {"class": "p-name vcard-fullname d-block overflow-hidden"}).contents
name = name_tag[0].strip()
follow_tag = soup.find('span', {"class": "text-bold color-text-primary"}).contents
followers = follow_tag[0]
gucian = [prof, name, followers]
# print(gucians)
writer.writerow(gucian)
except:
print("finished")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment