简体   繁体   English

如何在Xidel输出中添加换行符?

[英]How to add line break to Xidel output?

I have my batch file to grab links using xidel, the output html doesn't contain line breaks to separate each link from the other one 我有我的批处理文件以使用xidel捕获链接,输出html不包含换行符以将每个链接与另一个链接分开

@echo off
for /f "delims=" %%a in ('wmic OS Get localdatetime  ^| find "."') do set dt=%%a
set YYYY=%dt:~0,4%
set MM=%dt:~4,2%
set DD=%dt:~6,2%
set HH=%dt:~8,2%
set Min=%dt:~10,2%
set Sec=%dt:~12,2%

set stamp=page_%YYYY%%MM%%DD%@%HH%%Min%

xidel "http://www.mywebsite.com/mywebpage" --html -e //BODY/DIV/B[2]/A > C:\Users\User\Desktop\%stamp%.html

Can I add something to xidel to separate each line with a line break? 我可以在xidel中添加一些内容以用换行符分隔每行吗?

You can use !(.,value) to interleave the output with a value, ie output value after every a element: 您可以使用!(.,value)将输出与值进行交错,即在每个元素之后输出值:

xidel "http://www.mywebsite.com/mywebpage" --html -e "//BODY/DIV/B[2]/A!(., '')" > C:\Users\User\Desktop\%stamp%.html

! is the map operator and exactly the same as the / operator, except that / raises an error if you mix elements and non-elements. 是地图运算符,与/运算符完全相同,除了/混合元素和非元素时/会引发错误。

On Linux you can also use the --output-separator option, but on Windows it is hard to pass a line break in an argument 在Linux上,您也可以使用--output-separator选项,但是在Windows上,很难在参数中传递换行符

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM