我有一个运行在本地主机上的ANGLE服务器,我想从AppleScrip调用它.场景是,我以Angular 列表的形式插入了一组tweet ID,它以本地主机的身份运行.现在,我在另一个浏览器中打开了相同的推文链接,现在我想阅读推文链接,获取推文ID,并调用Angular 服务器来 Select 相应的推文ID,然后单击提交按钮.推文ID始终是预定义的.

我可以读取推文链接并获取推文ID,但不能调用ANGLE服务器.你能推荐一下吗?

读取和获取推文ID的代码

display dialog "Name of the browser?" default answer "Safari"
set inp to text returned of result

global link1 -- declare y
set link1 to "" -- initialize y

tell application "System Events"
    if inp is "Google Chrome" then
        tell application "Google Chrome" to return URL of active tab of front window
    else if inp is "Safari" then
        tell the application "Safari" to set link to URL of front document
        set teststring to "https://twitter.com/Jimmy_Wine/status/1090281915238834176"
        set tweets to words of teststring -- convert string to list of words
        set tweetid to the last item of tweets
        return tweetid
    else
        return
    end if
end tell

Angular 图形用户界面

enter image description here

推荐答案

使用Automater并执行以下操作

AppleScrip

tell application "Safari"
    tell window 1
        tell current tab
            set URL to "http://localhost:4200/"
            delay 1
        end tell
    end tell
end tell

调用Jaavscript并执行以下操作

function run(input, parameters) {
    
var safari = Application("Safari");
safari.includeStandardAdditions = true;
    
var safari = Application("Safari");
safari.includeStandardAdditions = true;
var jsScript = "";
jsScript += "document.getElementById('your id name').click();"; 
jsScript += "document.getElementsByClassName('your class name')[0].click();";
jsScript += "document.getElementsByClassName('your class name')[0].click();";
safari.doJavaScript(jsScript, { in: safari.windows[0].currentTab });

return input;
}

它会点击特定的twetid并提交按钮来调用服务器,如果您使用id作为搜索字段,您可以通过id更改类名.

Angular相关问答推荐

将kendo—colorpicker的kendo弹出窗口附加到组件''

Angular路由不响应子路由的子路由

如何从URL中角下载图片?

列表和映射的SCSS语法

Angular 16模块中未使用的组件是否从Bundle 包中删除(树摇动)?

FromEvent不工作,本机事件绑定

Ng serve不工作,没有错误或消息来显示问题所在

NGX-Translate如何不得到404?

显示 1 个数据而不是所有 ngFor - Angular 11

您如何链接需要多个先前可观察对象的依赖订阅

Angular模板错误:Property does not exist on type component

使用 rxjs 处理刷新令牌

angular4应用程序中输入的最小值和最大值

如何处理解析器中的错误

什么是 Angular 4,我可以从哪里了解更多信息?

Angular 2 - 组件内的 formControlName

没有 ChildrenOutletContexts 的提供者 (injectionError)

No provider for Router?

无法绑定到 target,因为它不是div的已知属性

Angular2/4 中的ng-reflect-*属性有什么作用?