在哪里可以找到描述我可以与Selenium和Chrome网络浏览器一起使用的选项的文档?我想在Web浏览器中打开一个链接(获取凭据)但不要下载相应的文件(.pdf或.tiff或.jpeg).我在Windows 7笔记本电脑上使用Python 2.7,selenium 3.0.1和Chrome版本54.0.2840.99(以及chromedriver.exe).
# Chrome web browser.
options = webdriver.ChromeOptions()
options.add_argument('--ignore-certificate-errors')
#options.add_argument('--disable-download-notification') #doesn't seems to work
#options.add_experimental_option("prefs", {"download.default_directory","C:\Users\xxx\downloads\Test"}) # doesn't work
#options.add_experimental_option("prefs", {"download.prompt_for_download": False}) # doesn't seems to work
#options.add_experimental_option("prefs", {'profile.default_content_settings': {'images': 2}})# this will disable image loading in the browser
options.add_argument("user-agent="+user_agent_profile)
driver_main = webdriver.Chrome(chrome_options=options)
# Opening the web application portail.
driver_main.get("https://my_link")
Run Code Online (Sandbox Code Playgroud)
我找到了很多关于这个主题的讨论,但没有一个解决方案有效.例如:
add_experimental_option("prefs", {"download.default_directory","C:\Users\xxx\downloads\Test"})
Run Code Online (Sandbox Code Playgroud)
不适合我.
同样的:
add_experimental_option("prefs", {"download.prompt_for_download": False})
Run Code Online (Sandbox Code Playgroud)
(我也尝试"假").
而:
add_argument("user-agent="+user_agent_profile)
Run Code Online (Sandbox Code Playgroud)
似乎工作!
我不确定是什么问题
我得到的问题是,每当我打开名称文件(1)文件(2)....文件(99)的链接时,它开始下载文件,然后从100开始,它会打开一个弹出窗口"另存为" .所以我想要么根本不下载文件或者能够将它移动到"回收站"中的特定文件夹中.
如何找到与add_argument和add_argument一起使用的选项?我试着看看Chrome://关于/但我看不到直接的信件.
非常感谢.
干杯.
法比安.
我使用 Linux 服务器:
> cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.7 (Santiago)
Run Code Online (Sandbox Code Playgroud)
(来自维基百科: Red Hat Enterprise Linux 6是从Fedora 12分叉出来的
6.7, also termed Update 7, 22 July 2015 (kernel 2.6.32-573)
6.8, also termed Update 8, 10 May 2016 (kernel 2.6.32-642))
Run Code Online (Sandbox Code Playgroud)
内核
> uname -r
2.6.32-642.11.1.el6.x86_64
> uname -s
Linux
> uname -v
#1 SMP Tue Nov 15 22:57:18 EST 2016
> cat /proc/version
Linux version 2.6.32-642.11.1.el6.x86_64 (sandman@node3res7) (gcc version 4.4.7 20120313 (SuSE 4.4.7-17) (GCC) )
#1 …
Run Code Online (Sandbox Code Playgroud) 我使用Tensorflow 2.0.beta
与Python 3.6.6
上Mac OS
(夜间:tf-nightly-2.0-preview
2.0.0.dev20190721
但我从来没有设法把它与COMPAT模块的工作Tensorflow 2.0
)。
我正在尝试将tf.estimator
模型从Tensorflow 1.12
(完全工作)迁移到Tensorflow 2.0
. 这是代码:
# estimator model
def baseline_estimator_model(features, labels, mode, params):
"""
Model function for Estimator
"""
print('model based on keras layer but return an estimator model')
# gettings the bulding blocks
model = keras_building_blocks(params['dim_input'], params['num_classes'])
dense_inpout = features['dense_input']
# Logits layer
if mode == tf.estimator.ModeKeys.TRAIN:
logits = model(dense_inpout, training=True)
else:
logits = model(dense_inpout, training=False)
# Compute …
Run Code Online (Sandbox Code Playgroud) python-3.x google-cloud-platform keras tensorflow tensorflow-estimator
我安装了以下软件包(并非所有软件包都可以在两个平台上安装):
在 Windows 7 机器上:
Window 7
Run Code Online (Sandbox Code Playgroud)
在 RHEL7 Linux 机器上:
$ cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)
$ cat /proc/version
Linux version 3.10.0-514.26.2.el7.x86_64 (sandman@node3res7) (gcc version 4.8.5 20150623 (SuSE 4.8.5-11) (GCC) ) #1 SMP Tue Jul 4 13:45:36 UTC 2017
Run Code Online (Sandbox Code Playgroud)
在 Windows 上,登录名和密码按预期存储在安全的旧版本中,无需任何其他密码。我认为 WinVaultKeyring 只有在正确的用户登录时才能解锁,前提是我正确理解了所有内容:
>>> from keyring import get_keyring
>>> get_keyring()
<keyring.backends.Windows.WinVaultKeyring object at 0x000000000361CAC8>
Run Code Online (Sandbox Code Playgroud)
在 Linux 上,它有点不同,当您开始存储登录名和密码时,会询问额外的密码。每次我需要访问登录+密码时,都会请求最后一个密码:Please enter …
我使用 Ubuntu 18.10 在 GCP 上创建了一个 VM 实例。当我在没有任何修改的情况下通过 SSH 连接 VM 并尝试:
gcloud info
Run Code Online (Sandbox Code Playgroud)
我收到了一些警告:
System PATH: [/snap/google-cloud-sdk/66/usr/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/game
s:/snap/bin]
Python PATH: [/snap/google-cloud-sdk/66/lib/third_party:/snap/google-cloud-sdk/66/lib:/snap/google-cloud-sdk/66/usr/lib/python2.7/:/snap
/google-cloud-sdk/66/usr/lib/python2.7/plat-x86_64-linux-gnu:/snap/google-cloud-sdk/66/usr/lib/python2.7/lib-tk:/snap/google-cloud-sdk/6
6/usr/lib/python2.7/lib-old:/snap/google-cloud-sdk/66/usr/lib/python2.7/lib-dynload]
Cloud SDK on PATH: [False]
Kubectl on PATH: [False]
WARNING: There are old versions of the Google Cloud Platform tools on your system PATH.
/usr/bin/snap
Run Code Online (Sandbox Code Playgroud)
如果我尝试通过以下方式进行身份验证:
sudo gcloud auth configure-docker
Run Code Online (Sandbox Code Playgroud)
我懂了:
WARNING: `docker-credential-gcloud` not in system PATH.
gcloud's Docker credential helper can be configured but it will not work until this is corrected.
WARNING: `docker` not …
Run Code Online (Sandbox Code Playgroud) credentials virtual-machine docker google-cloud-platform gcloud
我有一个 Docker 镜像,我可以运行它:
docker run -it --entrypoint="/bin/bash" gcr.io/docker:tag
Run Code Online (Sandbox Code Playgroud)
然后我可以通过以下方式获取脚本:
root@86bfac2f6ccc:/# source entrypoint.sh
Run Code Online (Sandbox Code Playgroud)
该脚本如下所示:
more entrypoint.sh
#!/bin/bash
. /env.sh
. /root/miniconda3/etc/profile.d/conda.sh
conda activate base
exec "$@"
Run Code Online (Sandbox Code Playgroud)
激活基础环境:
(base) root@86bfac2f6ccc:/#
Run Code Online (Sandbox Code Playgroud)
到目前为止一切顺利,但我没有设法将其包含在Dockerfile
或 作为参数中docker run
:
我尝试了很多东西:
例如:
docker run -it --entrypoint="/bin/bash" gcr.io/docker:tag source entrypoint.sh
/bin/bash: source: No such file or directory
Run Code Online (Sandbox Code Playgroud)
但是脚本存在并且可以执行:
docker run -it --entrypoint="/bin/ls" gcr.io/docker:tag -la
...
-rwxr-xr-x 1 root root 94 Apr 26 20:36 entrypoint.sh
...
Run Code Online (Sandbox Code Playgroud)
或者:
docker run -it --entrypoint="/bin/bash" gcr.io/docker:tag ". /entrypoint.sh"
/bin/bash: . /entrypoint.sh: …
Run Code Online (Sandbox Code Playgroud) docker ×2
python-3.x ×2
tensorflow ×2
bash ×1
conda ×1
credentials ×1
download ×1
entry-point ×1
file ×1
gcloud ×1
keras ×1
libstdc++ ×1
linux ×1
python-2.7 ×1
rhel6 ×1
rhel7 ×1