0

Is there a way to grep html text from a curl request and output grab the value that is between two html tags?

More specifically the input value of a form?

2

You can read content out of html downloaded via curl, using a mixture of the regular UNIX commands (so grep, awk, etc.) Exactly how depends on exactly what the form looks like and how you want to interpret it.

You can also do it with perl and other languages which have libraries which make it easier.

However, input forms only have content in the fields when some person or process fills it in locally before submitting it via a POST (or less likely a GET) request.

Input forms can have default values obviously, but it seems what you're asking is if you can somehow pull the data out of a form that's been filled in, the answer is not from curl, because curl asks the web server for the web page and you get an empty form.

Maybe you could clarify what you're trying to achieve.

  • Good enough. I'll try a different approach. – chrisjlee Jun 24 '11 at 16:37
0

There is

They are inspired by the json parser jq and offer similar syntax and behavior:

curl -s https://news.ycombinator.com/ | pup 'table table tr:nth-last-of-type(n+2) td.title a attr{href}'

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.