Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 2 down vote accepted

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.

share|improve this answer
Good enough. I'll try a different approach. – chrisjlee Jun 24 '11 at 16:37

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}'
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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