問題描述
我使用 Selenium & 創建了一個小型網絡抓取應用程序.chromedriver 用于將內容輸出到 excel 文件的項目.不幸的是,我為這個應用程序開發的人并不是最精通技術的人.
所以我的問題是如何與這些人分享這個應用程序?
我查看了 py2exe.org,但它在創建可執行文件時沒有考慮到 chromedriver.有沒有更好的方法來做到這一點,而這些人不必手動將文件添加到他們的usr/bin"?
你可以在 pyinstaller 的幫助下做到這一點
我使用 Selenium & 創建了一個小型網絡抓取應用程序.chromedriver 用于將內容輸出到 excel 文件的項目.不幸的是,我為這個應用程序開發的人并不是最精通技術的人.
所以我的問題是如何與這些人分享這個應用程序?
我查看了 py2exe.org,但它在創建可執行文件時沒有考慮到 chromedriver.有沒有更好的方法來做到這一點,而這些人不必手動將文件添加到他們的usr/bin"?
你可以在 pyinstaller 的幫助下做到這一點
a> :以下是適用于 Windows 的解決方案,但 pyinstaller 表示它也可以在 Mac OS 上運行.
步驟是:
注意,傳遞時需要在Scriptname.spec中提供chromedriver的詳細信息
spec 文件的示例內容:
# -*- 模式:python -*-block_cipher = 無a = 分析(['Scriptname.py'],pathex=['Pathofproject'],二進制文件=[('C:\Python27\chromedriver.exe', '**.\selenium\webdriver**')],數據=[],隱藏進口=[],鉤子路徑=[],runtime_hooks=[],排除=[],win_no_prefer_redirects=假,win_private_assemblies=假,密碼=塊密碼)pyz = PYZ(a.pure, a.zipped_data,密碼=塊密碼)exe = EXE(pyz,a.腳本,exclude_binaries=真,name='createEVIPorg_Automation_new',調試=假,條=假,upx=真,控制臺=真)科爾=收集(exe,a.二進制文件,a.zip 文件,a.數據,條=假,upx=真,name='**腳本名**')
您需要更新腳本名稱、腳本所在的項目路徑、spec 文件中 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?
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"?
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.
Steps are:
Note you need to provide the details of chromedriver in Scriptname.spec when passing the
Sample content of spec file:
# -*- 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**')
You need to update the Scriptname, project path where you script lies, path of chromedriver in spec file
這篇關于使用 chromedriver & 創建 Python 可執行文件硒的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!