Reputation: 115
xidel https://www.url.com/folder -e "<button class="btn" type="BUTTON" onclick="self.location='https://www.url.com/folder/2'">Next ></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 ></button>
Do I have to escape some characters. The syntax is confusing. I am using this on the commandline on windows, latest version.
Upvotes: 1
Views: 241
Reputation: 321
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
Upvotes: 2