代码之家  ›  专栏  ›  技术社区  ›  user3108268

在cmd上转义哪些字符以使用Xidel脚本

  •  0
  • user3108268  · 技术社区  · 6 年前

    使用 Xidel

    for /f "usebackqDELIMS=" %a in (`^"xidel -s file.html -e 'json(//script[@type="application/ld+json"])/(string)()'^"`) do set "string=%a"
    

    在命令输出中运行时,会给出:

    /(字符串()'“`)此时是意外的。

    我想我需要转义一些字符,遵循以下文档 http://www.robvanderwoude.com/escapechars.php 我尝试了很多选择,对不同的字符使用胡萝卜,对[]使用反斜杠,但仍然会出现更多错误。

    是否有某个字符需要转义或更多,或者根本不是这样?

    1 回复  |  直到 6 年前
        1
  •  1
  •   Reino    6 年前

    我现在明白了 I wrongfully assumed you were on Linux Examples #9和10):

    FOR /F "delims=" %%A IN ('xidel -s file.html -e "json(//script[@type='application/ld+json'
    ])/(string)()"') DO SET "string=%%A"
    

    FOR /F "delims=" %%A IN ('xidel -s file.html -e "string:=json(//script[@type='application/
    ld+json'])/(string)()" --output-format^=cmd') DO %%A