iMacros / Firefox /格式化结果 [英] iMacros / Firefox / format result

查看:164
本文介绍了iMacros / Firefox /格式化结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用javascript中的(简化)代码提取网站的某些部分。

I'm trying to extract some part of a website with this (simplified) code in javascript.

macro2 = "CODE:";
macro2 += "TAG POS={{i}} TYPE=H2 ATTR=TXT:* EXTRACT=TXT" + "\n";
macro2 += "SAVEAS TYPE=EXTRACT FOLDER=U:\imacros FILE=test.csv" + "\n";

因此,我得到正确的值,并保存在csv中。到目前为止没有问题。
但是网站的标记是:

So, I get the right values and the are saved in the csv. So far no problem. But the markup of the website is:

<h2>
    content
</h2>

因此,我的csv中的每个值都添加了额外的硬回报。
有没有办法避免这种情况?有一些HTML标签剥离或某些?

So, each value in my csv is added with an extra hard return. Is there any way to avoid this? With some HTML tag stripping or something?

任何输入都将非常感谢!
谢谢。
/ jurgen

Any input will be much appreciated! Thank you. /jurgen

推荐答案

将第2行和第3行之间:

put this between the line 2 and 3:

macro2 += 'SET !EXTRACT EVAL("var text=\\"{{!EXTRACT}}\\";var text = text.replace(\'\\\\n\',\'\',\'g\');text;")' + "\n";

或更短:

macro2 += 'SET !EXTRACT EVAL("var text=\\"{{!EXTRACT}}\\";var text = text.trim();text;")' + "\n";

这篇关于iMacros / Firefox /格式化结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆