Skip to content

Ability to execute different commands on multiple selectors #169

Open

Description

@tathastu871

Eg.
curl 'example.com' | pup 'a, td'
But if i need to reformat the output selectively using linux commands like sed awk tr etc.

curl example.com | pup 'a (command to execute on 'a' tags, td (command to execute on 'td' tags)
Just like tee and pee from moreutils of linux.

Pup will extract the multiple selector and pipe it to defined command. and finally pipe the formatted output of all selectors to stdout

Activity

  1. tathastu871 commented on Dec 29, 2021

    @tathastu871
    Author

    Please reply.
    It is highly needed because if user wants to parse two selectors and selectively format the output of each selector.

    It prevents the crawling of same site two times for two selectors

  2. gromgit commented on Dec 29, 2021

    @gromgit

    It prevents the crawling of same site two times for two selectors

    Have you considered just dumping the output of curl to a temp file, and running pup off that instead?

    curl -o /tmp/example.html example.com
    pup 'a (command to execute)' < /tmp/example.html
    pup 'td (command to execute)' < /tmp/example.html
    

    Much easier than waiting for a feature that will most likely never come, given that this project has outstanding PRs going back four years: https://github.com/ericchiang/pup/pulls

  3. amitbha commented on Jan 23, 2022

    @amitbha

    Highly recommend xidel, support xpath selector

  4. tathastu871 commented on Jan 26, 2022

    @tathastu871
    Author

    It prevents the crawling of same site two times for two selectors

    Have you considered just dumping the output of curl to a temp file, and running pup off that instead?

    curl -o /tmp/example.html example.com
    pup 'a (command to execute)' < /tmp/example.html
    pup 'td (command to execute)' < /tmp/example.html
    

    Much easier than waiting for a feature that will most likely never come, given that this project has outstanding PRs going back four years: https://github.com/ericchiang/pup/pulls

    curl site | tee >(pup a | command) >(pup td | command)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions