简体   繁体   English

使用Python打开链接后,在浏览器控制台中自动运行脚本

[英]Automatically Run a Script in my Browser console after opening a link using Python

I want to run some JavaScript in my browser DevTools console. 我想在浏览器DevTools控制台中运行一些JavaScript。 So far, I have opened up a specific website only through it. 到目前为止,我仅通过它打开了一个特定的网站。 Can it be done in Python? 可以用Python完成吗?

Right now, I am using the following code: 现在,我正在使用以下代码:

url = 'http://some-website.com/'

webbrowser.open(url)

What I want to do now is open up the DevTools console panel and then run a script through it automatically? 我现在想做的是打开DevTools控制台面板,然后自动通过它运行脚本? Can it be done by using Python or some other tool along with Python? 是否可以通过使用Python或其他工具以及Python来完成?

I don't belive this can be done, as 我不相信这可以做到,因为

ChromeDriver 2 and the DevTools windows both compete for the same automation channel, and ChromeDriver automatically closes the DevTools window in order for it to work. ChromeDriver 2和DevTools窗口都争夺同一个自动化通道,ChromeDriver自动关闭DevTools窗口以使其正常工作。

See here for more: Chrome Developer Tools closes instantly when attempting to debug WebDriver E2E test 查看更多信息: 尝试调试WebDriver E2E测试时,Chrome开发者工具会立即关闭

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用浏览器 JavaScript 的要求运行 python 脚本 - Run a python script using requirements with browser JavaScript 我的JavaScript第14行( <script> inside HTML) code will not run automatically, It will only run in the chrome developer console manually - Line 14 of my JavaScript(<script> inside HTML) code will not run automatically, It will only run in the chrome developer console manually 链接脚本时,脚本会自动运行吗? - When you link a script, is it automatically run? 单击链接后运行脚本 - Run script after click on the link 当我在 Google Apps 脚本中运行 GET 请求时,如何在浏览器选项卡打开后自动关闭它 - How to automatically close a browser tab after it opens when I run a GET request in a Google apps script 在 web 浏览器中运行脚本 python - Run script python in web browser JS脚本在浏览器控制台或FireBug控制台上运行是否有时间限制? - Is there a Time Limit for a JS script to run on the Browser Console or FireBug Console? 在其他浏览器中打开链接 - Opening a link in a different browser 使用 window.open() 打开一个带有链接的新标签,我希望该标签在 15 秒后自动关闭 - opening a new tab with a link using window.open() and i want that tab close automatically after 15sec 重定向到下一页后如何在控制台中自动运行 javascript - how to automatically run a javascript in console after redirecting to the next page
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM