简体   繁体   中英

xidel template extract from button tag

xidel https://www.url.com/folder -e "<button class="btn" type="BUTTON" onclick="self.location='https://www.url.com/folder/2'">Next &gt;</button>"

I am trying to extract what's in between the single quotes with this xidel template and I am getting nowhere fast.

<button class="btn" type="BUTTON" onclick="self.location='{.}'">Next &gt;</button>

Do I have to escape some characters. The syntax is confusing. I am using this on the commandline on windows, latest version.

At first I tried:

xidel -s https://www.fanfiction.net/s/12963528/1/Forced-Return -e "<button>{@onClick}</button>*"

but that gave me 5 results of buttons with an onClick attribute, so I needed to be more specific:

xidel -s https://www.fanfiction.net/s/12963528/1/Forced-Return -e "<div style='clear:both;text-align:right;'><button>{@onClick}</button></div>"

which will output: self.location='/s/12963528/2/Forced-Return'

So, now we need to get rid of the prefix and single quotes... RegEx is fine for that:

xidel -s https://www.fanfiction.net/s/12963528/1/Forced-Return -e "<div style='clear:both;text-align:right;'><button>{extract(@onClick,'=.(.*).',1)}</button></div>"

This will output what you wanted: /s/12963528/2/Forced-Return

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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