问题描述
我使用Selenium&用于将内容输出到excel文件的项目的chromedriver.不幸的是,我为此应用程序开发的人并不是最精通技术的人.
I have created a small web scraping app using Selenium & chromedriver for a project that outputs the content into an excel file. The people I did this app for unfortunately aren't the most tech-savvy.
所以我的问题是如何与这些人共享此应用程序?
So my question is how can I share this app with these people?
我查看了py2exe.org,但在创建可执行文件时并未考虑chromedriver.还有什么更好的方法,而无需这些人手动将文件添加到他们的"usr/bin"?
I looked into py2exe.org, but it doesn't take the chromedriver into account when creating the executable. Any better ways of doing this, without these people having to add the files manually to their "usr/bin"?
推荐答案
您可以借助 pyinstaller :以下是在Windows上可以使用的解决方案,但是pyinstaller表示它也可以在Mac OS上使用.
You can do this with the help of pyinstaller : Below is the solution which work on Windows but pyinstaller says its capable of working on Mac OS also.
步骤是:
- 打开命令提示符
- 在cmd中转到存在脚本的项目路径
- 键入pyinstaller Scriptname.spec Scriptname.py(如果在屏幕上出现提示,请输入y/yes)
- 版本将位于项目的路径" \ dist \ Scriptname
请注意,传递
规格文件的示例内容:
# -*- mode: python -*-
block_cipher = None
a = Analysis(['Scriptname.py'],
pathex=['Pathofproject'],
binaries=[('C:\\Python27\\chromedriver.exe', '**.\\selenium\\webdriver**')],
datas=[],
hiddenimports=[],
hookspath=[],
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher)
pyz = PYZ(a.pure, a.zipped_data,
cipher=block_cipher)
exe = EXE(pyz,
a.scripts,
exclude_binaries=True,
name='createEVIPOrg_Automation_new',
debug=False,
strip=False,
upx=True,
console=True )
coll = COLLECT(exe,
a.binaries,
a.zipfiles,
a.datas,
strip=False,
upx=True,
name='**scriptname**')
您需要更新脚本名称,脚本所在的项目路径,规格文件中chromedriver的路径
You need to update the Scriptname, project path where you script lies, path of chromedriver in spec file
这篇关于使用chromedriver&创建Python可执行文件硒的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!