AppleScript:复制剪贴板中列表的所有项目

时间:2016-05-25 07:33:43

标签: list google-chrome safari applescript

我从网站上的数据库中提取数据列表,

  1. 如何将列表中的项目结果设置到剪贴板,排除第一个结果只是一个错误的链接

  2. 如何在Chrome中使用此脚本而不是Safari?

    将dataINeedList设置为我的getInputByClass2(" sortable dataPersonId",1)      - 要获得第十个值,请使用此 - > allData的第10项

    to getInputByClass2(theClass) -- this return a list of values
        tell application "Safari"
            set r to do JavaScript "var outPut=[]; var arr=document.getElementsByClassName('" & theClass & "');for (var i in arr) {outPut.push(arr[i].innerHTML)};outPut;" in document 1
        end tell
        return strings of r --- this remove all 'Missing Value' from a list of strings
    end getInputByClass2
    
    set listSize to count of dataINeedList ## number of dataINeed founds
    
    set theResult to item 2 of dataINeedList
    
    ##repeat with theItem in dataINeedList ## not working
    ##  set the clipboard to theItem ##
    ##end repeat ##
    

1 个答案:

答案 0 :(得分:1)

基本上,它是这样的:

set x to {"a", "b", "c"}
set the clipboard to items 2 thru -1 of x