2

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

@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?

M. A.
  • 424
  • 6
  • 21
  • 1
    You got your answer, but as a sidenote, Xidel can also generate your timestamp: `-e "'page_'||replace(replace(substring(current-dateTime(),0,17),'[-:]',''),'T','@')"`. – Reino May 10 '19 at 11:23
  • Seeing my silly 2 year old comment now, I'd have to say, this can be done much more efficiently with just 1 function: `-e "format-dateTime(current-dateTime(),'page_[Y][M01][D01]@[H01][m01]')"`. – Reino Jul 31 '21 at 16:48

1 Answers1

2

You can use !(.,value) to interleave the output with a value, i.e. output value after every a element:

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

BeniBela
  • 16,412
  • 4
  • 45
  • 52