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

Feature idea: Add "--exec" to allow for looping through results #78

Open
MaffooBristol opened this issue Jul 8, 2017 · 2 comments
Open

Comments

@MaffooBristol
Copy link

I wanted to use pup to mass download some files from a site, and it did a very good job of parsing the HTML. But then I had to pipe the results into a bash loop – it would be nice to have this built in with an --exec type flag, in a similar vein to how the find command works. Could have a different name, that's just my initial suggestion.

So, instead of this implementation:

curl http://www.mysite.com | pup 'a attr{href}' | while read i; do wget $i; done

You could have:

curl http://www.mysite.com | pup 'a attr{href}' --exec wget {} \;

Does that sound like a valid idea?
Thanks!

@ericchiang
Copy link
Owner

This sounds like xargs is what you want https://linux.die.net/man/1/xargs

@sbmkvp
Copy link

sbmkvp commented Oct 3, 2023

parallel is another feature rich alternative to achieve this

curl http://www.mysite.com | pup 'a attr{href}' | parallel "wget {}"

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

3 participants