Created
February 17, 2020 13:46
-
-
Save VISWESWARAN1998/cf74dd0890534ad3e72f326e46460cd3 to your computer and use it in GitHub Desktop.
Reporting the spam
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
# 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