I want to collect some statistics of my chromium build and for that purpose I want to send some very simple data (for example just a string) with simple GET or POST request for example in browser startup stage in Launch browser function: link to code and in other similar places.
There is a way to write it on bare C++ with sockets and bytes but to be honest it's bad way I think.
I tried to read the documentation but without examples it's quite difficult to write code. To find example I found some usages in tests like: link to the code but still it not so easy to get really necessary part from this for very simple purpose: just to send "hello world" to the server.
Can anyone help with simple example how to use chromium api to make this simple request?
How to initialize QuickStreamRequest (or I need other Request)?
Where to get QuickStreamFactory?
Which parameters to put into Request method?
How to put request data ("hello world") into request?
Very simple example will bee cool :)
Related
I was trying to make a webscraper in C++ (I know I could use some other language but I'm just trying to learn). There's a webpage I'm trying to get the html code to but the page changes after a second or two with the links I want. How do I make the program wait until sometime to return the html?
Edit: I want to make a curl call once and then wait some time and then do another curl call to the same webpage after some time. (Not open the link again as it would give the same page)
You have three options:
investigate the site and figure out how the javascript code is changing the page, then replicate that in C++ (either by hard-coding a URL or parsing parts of the page),
embed a full browser engine that understands JavaScript and click the link after it changes, or
abandon C++ and use a dedicated scraping tool like CasperJS or Scrapy or wring or ...
I would inspect the page and see if you can make option 1 work, but option 3 is by far the easiest approach.
There is a giveaway happening involving codes that need to be entered, and I wanted to make a program that would generate codes that could be entered, and then put them into the online form.
1) First off, I have already created the generator using C++, and I was wondering if there was a more efficient language for generating these types of things, and algorithms in general, but this is not as important.
2) The main part that I was wondering about was if (and how) there was a way that I could take all these codes and then input them online, without doing the manual work of copy-pasting.
You can create the HTTP Request in C++ and directly send it to the server.
To do so:
Figure out what the HTML form does (there's a Firefox Plugin called "Firebug" which shows all the Requests done by a Site). If you'r lucky, the form is simple calling a PHP script via a HTTP GET or POST Request.
Build the Request in your C++ Code (have a look at this: Send Http "Post" Request To Php Code in C or C++ if you have to make a POST Request)
Send the Request
Handle the Answer
Please excuse my bad english ;)
So I am using QTCreator (5.0/5.1) and I am trying to access a website in a way that allows me to access information.
I have built a gui (as this is faily easy) but I want to know how to go about connecting to a network in c++ for my first time.
so for example:
https://btc-e.com/api/2/btc_usd/ticker
I want to get all the information present to me there and store it, the parse it, I just don't know how to connect, to the site.
someone mentioned using the #include but I'm not sure how exactly to use it as well.
If you could provide an example that would be great!
Thanks!
For this kind of task you probably want to use the more high level Qt classes to retreive the page and parse the data. Qt provides classes for both HTTP retrieval and parsing JSON data.
Network Programming with Qt
JSON Support in Qt
Read over those documents, have an attempt at writing some code, then ask specific questions, giving the example code you've tried using and what results you're getting.
EDIT 01
Sounds like web sockets is what I want.
Technical Background:
I am familiar Clojure + ring + composure.
I am starting to learn ClojureScript. (Have lein-cljsbuild setup; have also spent time installing ClojureScript "manually" just to see how it works.) Have the basic (alert (greeting "ClojureScript")) demo working.
What I want to create:
I want to create a basic two person Notepad (i.e. Instant Messenger, or two-person IRC channel). I want there to be a Clojure Server. When a client connects it shows it a text bok; the user types in some words, the clojure updates to the other user.
Question
I need some help getting started on this. Google Closure is a big library, I would like to understand things like:
(1) how do I setup a basic connection to get my cljs code and my clj code to send each other data
(2) once my cljs code received new data, how do I get it do update the DOM?
I think these are the two main things -- and if I had this, it would provide a framework for understanding the rest of clojurescript.
Thanks!
I wrote an example app that does this using clojurescript, ring, and websockets via a Webbit server:
https://github.com/aiba/clojurescript-chat-example
Hope this helps!
You (I) probably want WebSockets.
More to be updated (if I produce actual working code.)
How do I get form data from HTML page using c++, as far as the basics of post and get?
EDIT: CGI is using apache 2 on windows, I got c++ configured and tested with with apache already.
The easiest way to access form data from an HTTP request is via CGI. This involves reading environment variables which is done using the getenv function.
First of all take a look at webtoolkit.
You might want to use that to make your life easier.
Second you can read about network protocols.
Third take a look at your webserver docs, they might provide such interface to create a deamon that will allow you to read the HTTP socket and the data that is sent over it.
On another note next time you write a question try to elaborate as much as possible.
Explain the use case and provide a test case.
You may use CgiCC library that gives you want you are looking for. You may also try some C++ web framework like CppCMS.