Created
August 5, 2021 10:53
-
-
Save zabir-nabil/3febf028fcac83c45008ca9aba039aa6 to your computer and use it in GitHub Desktop.
Find all the links from a list of websites and check if certain keywords are present in the homepage or not.
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
from selenium import webdriver | |
from bs4 import BeautifulSoup | |
from selenium.webdriver.chrome.options import Options | |
chrome_options = Options() | |
chrome_options.add_argument("--headless") | |
chrome_options.add_argument('--no-sandbox') | |
driver = webdriver.Chrome('/usr/bin/chromedriver', options=chrome_options) | |
ips = open("ip.txt", "r") | |
keywords = ["login", "denied", "username", "password", "Apache2"] | |
for ip in ips.readlines(): | |
try: | |
print("http://" + ip.strip(), end=" ") | |
driver.get("http://" + ip.strip()) | |
found = False | |
for k in keywords: | |
if k in driver.page_source: | |
print(f" [ found ]") | |
found = True | |
break | |
if found == False: | |
print(f" [ not found ]") | |
soup = BeautifulSoup(driver.page_source) | |
a_s = soup.find_all("a") | |
for a in a_s: | |
if a.get("href", None) != None: | |
if a["href"].startswith("http"): | |
print(a["href"]) | |
print("---------------------------------------------------") | |
except: | |
print("driver faild") |
Author
zabir-nabil
commented
Aug 5, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment