在 cmd 上转义哪些字符以使用 Xidel 脚本
What characters to escape on cmd to work with Xidel scripting
使用 Xidel 抓取 HTML:
for /f "usebackqDELIMS=" %a in (`^"xidel -s file.html -e 'json(//script[@type="application/ld+json"])/(string)()'^"`) do set "string=%a"
当运行它在CMD输出中给出:
/(string)()'"`) was unexpected at this time.
我假设我需要转义一些字符,遵循此文档http://www.robvanderwoude.com/escapechars.php我尝试了很多选项,对各种字符使用胡萝卜,对 [] 使用反斜杠,但不断出现更多错误。
是否有某个字符需要转义或更多,或者根本不是这种情况?
我现在看到了 I wrongfully assumed you were on Linux. In that case you have to fix the quoting (see 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
让 Xidel 为您分配变量。
使用 Xidel 抓取 HTML:
for /f "usebackqDELIMS=" %a in (`^"xidel -s file.html -e 'json(//script[@type="application/ld+json"])/(string)()'^"`) do set "string=%a"
当运行它在CMD输出中给出:
/(string)()'"`) was unexpected at this time.
我假设我需要转义一些字符,遵循此文档http://www.robvanderwoude.com/escapechars.php我尝试了很多选项,对各种字符使用胡萝卜,对 [] 使用反斜杠,但不断出现更多错误。
是否有某个字符需要转义或更多,或者根本不是这种情况?
我现在看到了 I wrongfully assumed you were on Linux. In that case you have to fix the quoting (see 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
让 Xidel 为您分配变量。