提取作者<class> id属性</class>的值

时间:2012-06-05 14:17:04

标签: applescript

我正在尝试通过Mac Twitter应用中的推文获取作者ID。

tell application "Twitter"
properties of item 3 of status of (home timeline of account 1)
end tell

enter image description here

tell application "Twitter"
author of item 3 of status of (home timeline of account 1)
end tell

enter image description here

如何隔离“128938832”?

解决方案:来自AppleScript-Users邮件列表的Chris刚回答了我的问题。 author属性具有用户标识属性。 user id of author of item 3 of status of (home timeline of account 1)返回“128938832”。

1 个答案:

答案 0 :(得分:1)

我没有Twitter,但如果没有条款来获取作者的ID,您可能会因强制错误并从错误消息中提取数字而作弊,例如:

tell application "Twitter" to try
    (author of item 3 of status of (home timeline of account 1)) as number -- force error
on error errmess -- extract info from the error message
    set here to (offset of quote in errmess) + 1 -- first quote
    set there to here + (offset of quote in (text here thru -1 of errmess)) - 2 -- second quote
    set authorID to text here thru there of errmess
end try