提取"网址"来自Json-Data和Imacros

时间:2017-11-29 19:59:07

标签: imacros

我正在使用iMacros for Firefox并希望从JSON文件中提取一些网址 我试图提取这些网址

{
      "names": {
        "name": "websites"
      },
      "urls": [
        {
          "id": 10,
          "url": "http://www.google.com"
        },
        {
          "id": 11,
          "url": "http://www.yahoo.com"
        },
        {
          "id": 12,
          "url": "http://www.amazon.com"
        }
      ]
    }

JSON文件如下所示:

VERSION BUILD=8601111 RECORDER=FX
TAB T=1
SET !ENCRYPTION NO
WAIT SECONDS=1
TAG POS=1 TYPE=TD ATTR=TXT:url  EXTRACT=TXT
TAG POS=2 TYPE=TD ATTR=TXT:url  EXTRACT=TXT
TAG POS=3 TYPE=TD ATTR=TXT:url  EXTRACT=TXT
SAVEAS TYPE=EXTRACT FOLDER=* FILE=links.txt

{{0}}

我的IMACROS代码:

map_id, key, value

谢谢。

1 个答案:

答案 0 :(得分:1)

尝试播放此宏:

SET !EXTRACT_TEST_POPUP NO
TAG POS=1 TYPE=* ATTR=* EXTRACT=TXT
SET !EXTRACT EVAL("var u = []; var a = JSON.parse('{{!EXTRACT}}').urls; for (i in a) u.push(a[i].url); u.join('[EXTRACT]');")
SAVEAS TYPE=EXTRACT FOLDER=* FILE=links.txt