Virustotal selenium Python 脚本

问题描述 投票:0回答:1

!pip 安装selenium !apt-get 更新 !apt-get install -y libgconf-2-4 !apt-get install -y libxss1 libappindicator1 libindicator7 !apt-get 安装 xvfb 从 selenium.webdriver.support.ui 导入 WebDriverWait 从 selenium.webdriver.support 导入预期条件作为 EC 从硒导入网络驱动程序 从 selenium.webdriver.common.by 导入 从 selenium.webdriver.common.keys 导入密钥 导入操作系统 导入时间

# Set up Chrome options
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
# Function to perform the blacklist check
def perform_blacklist_check(url):
    driver.get("https://www.virustotal.com/gui/home/search")

    # Wait for the input textbox to be present
    checkTxt = WebDriverWait(driver, 10).until(
        EC.presence_of_element_located((By.NAME, "searchInput"))
    )

    checkTxt.clear()
    checkTxt.send_keys(url)

    # Press Enter using Keys.RETURN
    checkTxt.send_keys(Keys.RETURN)

    # Wait for the result to be present
    result = WebDriverWait(driver, 20).until(
        EC.presence_of_element_located((By.XPATH, '/html/body/form/div[3]/div[2]/div[2]/div/div[2]/div[2]/span/div/div[3]'))
    )

    # Get the result and write it to a file
    result_text = str(result.text)
    with open('output.txt', 'a') as f:
        f.write(result_text)
        f.write('\n' * 10)
# List of URLs to check
urls = ["test.com"]

# Perform blacklist check for each URL
for url in urls:
    perform_blacklist_check(url)

# Close the browser
driver.quit()[enter image description here][1]
python selenium-webdriver shadow-dom
1个回答
0
投票

提供的 Python 脚本旨在自动使用 VirusTotal 网站根据数据库检查 URL 的过程。该脚本使用 Selenium 来控制无头 Chrome 浏览器,这使得它可以在没有图形用户界面的情况下运行。

但是,消息的初始部分似乎是 shell 命令,旨在在类 Unix 终端中运行,以通过安装 Selenium 及其依赖项来设置环境。这些命令在此聊天中将无法按预期工作,因为我们无法安装外部包或运行 Selenium。

要运行脚本,您需要在安装了 Python 以及 Selenium 和必要的浏览器驱动程序的本地环境中执行它。请务必遵循 Selenium WebDriver 的安装步骤,并确保在与网站自动交互之前遵守网站的服务条款。

© www.soinside.com 2019 - 2024. All rights reserved.