2014-03-26 115 views
1

我想获得applescript点击(链接),我已经发布了下面的代码,我已经尝试了很多方法,但我无法得到它的工作。此外,链接每次都是不同的,所以我不能将该链接复制到它。先谢谢了!同时这是所有的代码,用它做(我认为),我希望它在最后上传的日期点击:(链接)Applescript | Javascript - 点击使用Javascript的链接?

<div class="span4 offset1"> 
          <ul class="unstyled"> 
           <li>Monthly Views: <strong class="pull-right"><a href="#" class="data-na" data-original-title="" title="">NA</a></strong></li> 
           <li>Daily New Views: <strong class="pull-right">18,830</strong></li> 
           <li>Daily New Subscribers: <strong class="pull-right">33</strong></li> 
           <li>Total Views: <strong class="pull-right">298,481</strong></li> 
           <li>Total Channel Views: <strong class="pull-right">3,467</strong></li> 
           <li>Total Subscribers: <strong class="pull-right">649</strong></li> 
           <li id="date-of-last-upload">Date of Last Upload: <a href="https://www.youtube.com/watch?v=YVrV-OmDJcw&amp;feature=youtube_gdata" target="_BLANK">(link)</a><strong class="pull-right">14-01-10 @ 08:18:36 pm</strong></li> 
           <li class="clearfix">Partner: 
            <strong class="pull-right"> 
                                           TheDeeman25+user                             </strong> 
           </li> 
          </ul> 
         </div> 

回答

0

我不知道这是否是你正在寻找的答案但是你可以通过获取childNodes来获得锚标签的href属性的值。 JavaScript返回的值是您想要最终设置文档的URL。而不是使用点击,我得到所需的位置,并设置文档1的URL;结果/目标将与点击相同。

tell application "Safari" 
    tell document 1 
     set URL of it to do JavaScript "document.getElementById('date-of-last-upload').childNodes[1].href" 
    end tell 
end tell 

编辑:打开一个新的标签页的网址(如果打开的选项卡链接设置为自动的偏好),您可以更改set URL of it toopen location

tell application "Safari" 
    tell document 1 
     open location (do JavaScript "document.getElementById('date-of-last-upload').childNodes[1].href") 
    end tell 
end tell 
+0

正是我想要的,谢谢堆人! – user3460149

+0

另外,我将如何使它在新选项卡中打开? (即时通讯JavaScript) – user3460149

+0

我已编辑我的文章回答你的问题。 –