如何通过AppleScript的使用Javascript抢HTML片段 [英] How to grab HTML snippet via Applescript with Javascript

查看:557
本文介绍了如何通过AppleScript的使用Javascript抢HTML片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是我的详细情况。

我已经找到了如何登录到一个网站,而不是使用JavaScript,但使用按键,标签和收益,找到用户名和密码字段。我知道这可能是不可靠的网站改变,但现在我只是想保持简单。

我登录网站后,就像一个银行账号,我要抢账户余额,并将其导入到数字。

我已经找到了如何插入pdermined文本到数字的特定细胞中的$ P $,可能会展开来的对话框等,但是这不是我真正想要实现。

基本上我不知道我需要做抢从目前网站上的数据我已经登录后做研究,我意识到这是什么待办事项使用javascript。

目前,并把它应用到更大的计划,我只是想知道如何找到一个网站,我没有通过JavaScript登录到在Safari和显示AppleScript的编辑结果数据的数据。我试图找出我怎么能使用这个结果在另一个应用程序(EI号)进行显示。然后我会将此到其他网站,所以我想确切地知道在哪里可以找到数据。

我在想,股票网站将是一个很好的例子,但我有一个艰难的时间找到一个适合这个例子。

感谢您的帮助!


解决方案

  

我只是想知道如何定位,我没有一个网站的数据
  通过JavaScript登录到在Safari


这可能是easely用JavaScript做:有了它,你可以通过的名称 ID ,穿越他们的向上或的向内并得到这样的文本并的 HTML 内容。请告诉我们你尝试过和你得到哪些错误:没有人可以学习JavaScript为你



  

和在AppleScript的编辑结果显示的数据。


所有你需要做的从JavaScript传递一个变量的AppleScript是包含在你的js code return语句。

 属性myVar的:缺少值
告诉应用程序野生动物园
    设置myVar的做的JavaScript
变种myVar的=与& myVar的&放大器;;
myVar的= myVar的+ 1;
返回myVar的;
在文献1
告诉结束
显示对话框myVar的

做的JavaScript 命令,这是专门针对Safari浏览器,将返回其执行脚本返回的值相同。因此,您可以从网页到您的AppleScript保存任何价值。

Here is my situation in detail.

I have figured out how to login to a website, not using javascript, but using "keystrokes", "tabs" and "returns" to find the username and password fields. I know this can be unreliable as websites change but for now I am just trying to keep it simple.

After I log in to a site, like a bank account, I want to grab the account balance and import it to Numbers.

I have figured out how to insert a predermined text into a specific cell in Numbers and probably could expand that to dialog boxes ect, but that is not what I am really trying to accomplish.

Basically I don't know what I need to do to grab the data from the current website after I have logged in. Doing research I realize it is something todo with javascript.

For now and to apply it to the bigger plan, I just want to know how to locate data of a website that I do not have to log into in Safari via javascript and display the data in the results of Applescript Editor. And I am trying to figure out how I could use that result to display it in another application (ei Numbers). I then would apply this to other sites, so I would like to know exactly where to look to find the data.

I am thinking that stock websites would be a great example but I am having a tough time finding one that fits this example.

Thank you for your help!

解决方案

I just want to know how to locate data of a website that I do not have to log into in Safari via javascript

This can be easely done with JavaScript: with it you may get dom element(s) by class, name, id, traverse them upwards or inwards and get their properties like text and html content. Please tells us what have you tried and which error do you get: nobody can learn JavaScript for you.


and display the data in the results of Applescript Editor.

All you have to do to pass a variable from JavaScript to AppleScript is to include a return statement in your js code.

property myVar : missing value
tell application "Safari"
    set myVar to do JavaScript "
var myVar = " & myVar & ";
myVar = myVar + 1;
return myVar;
" in document 1
end tell
display dialog myVar

The do JavaScript command, which is specific to Safari, will return the same value returned by the script it executes. Hence, you may save any value from a webpage to your applescript.

这篇关于如何通过AppleScript的使用Javascript抢HTML片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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