Pyinstaller exe文件不适用于selenium

2024-09-28 22:22:34 发布

您现在位置:Python中文网/ 问答频道 /正文

我希望以下脚本作为可执行文件。。。它变成了建筑和一切。。。但是当我运行token.txt时,它不会生成一个token.txt(也作为admin)。我不知道它是完全不起作用还是只是文件创建部分。 但我认为它根本不起作用。。。在cmd中运行exe不显示打印。。。 此外,还将打开geckodriver.exe窗口。 当我不以管理员身份驾驶时,exe请求防火墙许可。 当我每一次启动exe时(实际上只在每一次启动时),会出现一个错误,显示: “无法执行脚本Etherscrape”(Ethersscrape是.exe的名称) 还有一个geckodriver.log显示错误:

*** You are running in headless mode. JavaScript error: resource://gre/modules/XULStore.jsm, line 66: Error: Can't find profile directory. 1591714269803 Marionette INFO Listening on port 54219 1591714270054 Marionette WARN TLS certificate errors will be ignored for this session

from selenium import webdriver
from selenium.webdriver.firefox.options import Options
from collections import defaultdict

counted = defaultdict(int)
tokenliste = []

options = Options()
options.headless = True
driver = webdriver.Firefox(firefox_options=options)


for x in range(1,10):
    my_url = "https://etherscan.io/tokentxns?ps=100&p="+str(x)
    driver.get(my_url)
    for i in range(1,100):
        xpath = "/html/body/div[1]/main/div[2]/div/div/div[2]/table/tbody/tr["+str(i)+"]/td[9]/a"
        p_element = driver.find_element_by_xpath(xpath)
        tokenliste.append(p_element.text)

for x in tokenliste:
    counted[x] += 1
print(counted)

with open("token.txt","w",encoding="utf-8") as f:
    for key, value in sorted(counted.items(), key=lambda item: item[1]):
        stri = str(key)+ ": " + str(value)+ "\n"
        f.write(stri)


Tags: infromimportdivtxttokenfordriver