Chrome的自动化 [英] Automating Chrome

查看:143
本文介绍了Chrome的自动化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到一些野生的事情发生时,我粘贴一些urlen codeD的Javascript插入火狐和Chrome的URL。是否有可能使用这种技术来告诉浏览器访问的URL,然后将其保存为文件?我试图自动化铬,硒显得极其艰巨。

修改:不幸的是,我忘了,更清楚在这里。让我解释。像wget的,卷曲等事情不会工作,因为我有过一些这些脚本登录就搞定了。而我看​​着iMacros的,却发现我不能让他们在命令行中,除了在Windows上运行,除非我支付$ 499包。 GCEs的一些其它优点是dev的平台是自由开放一定程度,它们是跨平台的。 (我用Linux的。)

修改:在这一点上,我了解谷歌Chrome浏览器扩展。他们似乎很容易建立,将让我(我想)告诉浏览器打开一个新标签,转到一个页面,操作DOM的网页上(如填充一些领域和登录),然后操纵DOM响应页面上。 GCEs不让你做的文件I / O,所以他们不喜欢与XPCOM Firefox的扩展,但你可以得到解决,通过使用AJAX将数据发送到后端脚本(如LAMP服务器上的PHP脚本),以节省该数据。

修改:顺便说一句,这是稍微偏离主题(但我想补充澄清)在Javascript中,我提到的,当你操作DOM创建一个URL是那些野东西的看起来像这样:

 的javascript:(函数(){...您的网址恩codeD此处的JavaScript ...})();


解决方案

解决的办法似乎是使自己的谷歌Chrome扩展(GCE)。这是很容易约4小时内学习,如果你知道如何做小幅Javascript高级的东西,是非常强大的。我可以用标签API来创建一个新的标签,进入到特定的URL。那么我可以jQuery注入该URL并使其操作DOM或做任何事情,我们通常可以用jQuery做。我不能做文件I / O,但有两个解决方法。一,我能强制浏览器从远程位置下载文件,我可以把从当前页的数据备份到通过jQuery的$。获得()或$。员额()调用一个远程服务器。

I've seen some wild things happen when I paste some urlencoded Javascript into a URL on Firefox and Chrome. Is it possible to use this technique to tell Chrome to visit a URL and then save it as a file? I'm trying to automate Chrome, and Selenium looked extremely daunting.

EDIT: Unfortunately, I forgot to be more clear here. Let me explain. Things like wget, curl, etc. won't work because I have to get through logins in some of these scripts. And I've looked at iMacros, but found that I can't get them to run from command line except on Windows, unless I pay for the $499 package. Some other advantages of GCEs are that the dev platform is free and open to some degree, and they are cross-platform. (I use Linux.)

EDIT: At this point, I'm learning about Google Chrome Extensions. It appears they are easy to build and will let me (I think) tell the browser to open a new tab, go to a page, manipulate the DOM on that page (such as populating some fields and logging in), and then manipulate the DOM on the response page. GCEs don't let you do File I/O, so they are not like Firefox Extensions with XPCOM, but you can get around that by using AJAX to send data to a backend script (like a PHP script on a LAMP server) to save that data.

EDIT: By the way, and this is slightly off-topic (but I add to clarify) those "wild things" in Javascript that I mentioned were when you manipulate the DOM creating a URL that looks like so:

javascript:(function(){...your URL-encoded Javascript here...})();

解决方案

The solution appears to be to make one's own Google Chrome Extension (GCE). It is easy to learn within about 4 hours if you know how to do slightly advanced Javascript stuff, and is very powerful. I can use the Tabs API to create a new tab and go to a specific URL. I can then inject jQuery into that URL and make it manipulate the DOM or do anything we normally can do with jQuery. I can't do file I/O, but there are two workarounds. One, I can force the browser to download a file from a remote location, and I can send data from the current page back up to a remote server via jQuery's $.get() or $.post() calls.

这篇关于Chrome的自动化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆