Skip to content

Instantly share code, notes, and snippets.

@VISWESWARAN1998
Created February 17, 2020 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VISWESWARAN1998/cf74dd0890534ad3e72f326e46460cd3 to your computer and use it in GitHub Desktop.
Save VISWESWARAN1998/cf74dd0890534ad3e72f326e46460cd3 to your computer and use it in GitHub Desktop.
Reporting the spam
# SWAMI KARUPPASWAMI THUNNAI
import requests
import time
from bs4 import BeautifulSoup
from selenium import webdriver
browser = webdriver.Chrome()
browser.get("https://www.github.com/login")
time.sleep(10)
r = requests.get("https://github.com/akdnfbf", headers={"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:73.0) Gecko/20100101 Firefox/73.0"})
soup = BeautifulSoup(r.content, "html.parser")
links = soup.find_all("a", class_="content-title no-underline")
url_list = []
for link in links:
link_url = "https://github.com" + link.get("href")
url_list.append(link_url)
message = """
This is a spam. Please close it.
Wrote a small script to automate the reporting, Just like the spammer did.
Regards,
Visweswaran N
"""
for url in url_list:
browser.get(url)
try:
text = browser.find_element_by_xpath('//*[@id="new_comment_field"]')
text.send_keys(message)
browser.find_element_by_xpath('/html/body/div[5]/div/main/div[3]/div/div/div/div[2]/div/div[1]/div/div[2]/div/form/div/div/div/div/div[2]/button').click()
except:
pass # some might actually closed it
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment