Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepend baseurl before following #9

Closed
Fuzzyma opened this issue Oct 28, 2016 · 5 comments
Closed

Prepend baseurl before following #9

Fuzzyma opened this issue Oct 28, 2016 · 5 comments

Comments

@Fuzzyma
Copy link

Fuzzyma commented Oct 28, 2016

Is there a way to prepend the baseurl before every link before following? In my case I have relative links in a json file which I want to follow. I need to add the url to the links before I can follow them.

Is this even possible? Thats my command so far:

xidel file.json -f '$json()["url"]' -e '//html'
@Fuzzyma
Copy link
Author

Fuzzyma commented Oct 28, 2016

Yes it is possible with transform and concat

xidel file.json -f 'transform($json()("url"), function($e){ concat("http://baseUrl.com", $e) })' -e ...

@Fuzzyma Fuzzyma closed this as completed Oct 28, 2016
@benibela
Copy link
Owner

That's a surprise. I thought transform would only work with XML.

It is supposed to be done with the mapping operator !

xidel file.json -f '$json()("url") ! concat("http://baseUrl.com", .) ' -e ...

or

xidel file.json -f '$json()("url") ! resolve-uri(., "http://baseUrl.com") ' -e ...

@Fuzzyma
Copy link
Author

Fuzzyma commented Oct 29, 2016

Well that solution looks way better. However: I am already done with my task :D. Thanks anyway! Is this documented somewhere?

Also: Is there a way to retry requests, when they timeout?
Because I get errors like this: Error: -3 Internet connection reseted

@benibela
Copy link
Owner

Is this documented somewhere?

It is just XPath 3: https://www.w3.org/TR/xquery-30/#id-map-operator

Also: Is there a way to retry requests, when they timeout?

--error-handling=xx=retry

for an error code xx. Or xx for all 2 digit codes

@Fuzzyma
Copy link
Author

Fuzzyma commented Oct 29, 2016

cool thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants