1

How would I go about using libCURL to see if a page has certain text? Like, if "yahoo.com" contains the word 'blue' return true, otherwise return false. Is this possible?

rmaes4
  • 555
  • 9
  • 22
  • 2
    Split the question in two: How to get a page's contents into a string (http://stackoverflow.com/questions/9786150/save-curl-content-result-into-a-string-in-c) and how to search for a substring within a string (http://stackoverflow.com/questions/346858/how-do-you-search-a-stdstring-for-a-substring-in-c) – Pablo Apr 15 '12 at 20:11
  • @Pablo I now have it successfully writing to the readBuffer variable but now I am stuck at comparing the readBuffer with my string. How do I do that? I simply want to know if my string is inside the other and have it return true. – rmaes4 Apr 15 '12 at 20:33

2 Answers2

0

Take a look at this page, providing documentation and examples for libcurl. For example "Parsing HTML" with libxml. Maybe you simply can retrieve the page and parse through the buffer for your keyword, string or whatever.

Sebastian
  • 8,046
  • 2
  • 34
  • 58
0

You could play around with curl and grep:

curl www.yahoo.com | grep blue

If you see some markup, then blue is found. Of course you should elaborate some grep options to adapt the output to your needs.

Manuel Leuenberger
  • 2,327
  • 3
  • 21
  • 27
  • Grep is not installed on Windows, but you can get GnuGrep or other alternatives, [see this question](http://stackoverflow.com/questions/87350/what-are-good-grep-tool-for-windows). – Manuel Leuenberger Apr 15 '12 at 20:30
  • How do I save the output of a command like: `curl www.yahoo.com | grep blue`? So I can use a systemcall in `C++` and save the output in a variable. – bog Apr 20 '16 at 07:36