我正在创建宏,但遇到问题。
每次我重新加载时,该网站都会更改其 iframe 名称。所以我想获取 iframe 名称并将其放入变量中。问题是我不知道如何从提取的 html 中获取 iframe 名称
TAG POS=7 TYPE=iframe ATTR=ID:* EXTRACT=HTM
<iframe src="https://www.facebook.com/plugins/comments.php?api_key=271750421132&channel_url=http%3A%2F%2Fstatic.ak.facebook.com%2Fconnect%2Fxd_arbiter%2F7tUlZKGPU61.js%3Fversion%3D41%23cb%3Df39559b33f3fe54%26domain%3Dwww.collegehumor.com%26origin%3Dhttp%253A%252F%252Fwww.collegehumor.com%252Ff2b6c86b5ce5e7%26relation%3Dparent.parent&colorscheme=light&href=http%3A%2F%2Fwww.collegehumor.com%2Ftoplist%2F6754891%2Fthe-biggest-pet-peeves&locale=en_US&mobile=false&numposts=10&order_by=social&sdk=joey&skin=light&version=v2.0&width=570" class="fb_ltr" title="Facebook Social Plugin" style="border: medium none; overflow: hidden; height: 2589px; width: 607px; outline: 1px solid blue;" scrolling="no" name="f17c627e8f47218" id="f31982b5a1b9c64"></iframe>
我只需要获取 iframe id,即 f31982b5a1b9c64
。我对 javascript 知之甚少,所以我似乎无法弄清楚这一点。
最佳答案
如果您想获取 iframe 名称,请添加此行:
SET frameName EVAL("'{{!EXTRACT}}'.match(/name="(\w*)"/)[1];")
或者这个来获取 iframe id:
SET frameId EVAL("'{{!EXTRACT}}'.match(/id="(\w*)"/)[1];")
关于javascript - imacros 从提取的 html 中剪切了 txt 的一部分,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31996945/