Tell me, please, how can C / C ++ interact with an HTML page? And is it even possible?

Never worked with networks before. I don’t need to go deep, it’s enough to drive numbers into a form . At the same time I will be glad to links to useful materials on the topic of network programming under Linux in general.

  • one
    cpp-netlib - Fe1iX
  • You want to emulate the work of a user who fills out a form and sends it to a server or a micro-server that receives a request from a browser (or other program) and responds to it. - avp

4 answers 4

And is it even possible?


It is enough to drive in the form.

The task is clear. Those. essentially, you need to emulate a user experience. Well. I would recommend to turn my attention to the Qt library and, in particular, its QtWebKit component .

    There is also such a very common library:

    And an example of how to work with forms using this library:

    There are in the repositories of all Linux distributions (well, maybe only in which there are absolutely no exotic ones).

    There is also a C ++ wrapper:

    • Only the language for this is probably desirable to take a higher level - in order to press fewer keys. - alexlz
    • I looked and found that curl emulates a client (for example, a browser), i.e. he makes connect, etc. I did not understand from the question whether this is required or vice versa, work as a server, i.e. get a request, send a form, get a completed form, etc. Maybe I didn’t look carefully at the site, tell me if curl has any functions to work as an http server (there is probably a html parsing (I haven’t looked at it yet)). Actually this question interests me in my work (to write or search for a library or tear out pieces from the server). And then, as they say, to the catcher and the beast ... - avp

    For network programming in Linux, Qt can be used. Also, almost in every book on programming in Linux, it is written about network programming (mostly in C).

      Zifir in the form to drive on the line is not accepted. If you need to write the server part, it is better to use sockets directly. Either in pure form under C, or in the form of different wrappers for Java, PHP, Python, etc. In fact, system programming is not as difficult as it is painted. And sockets in the form of system calls are also not so complicated. You can master the basics in a couple of days. Another thing is that it is necessary to prescribe the http protocol with handles.

      • @mikillskegg, don't you know about the http-html C server libraries? - avp