class WebDriver{
bool first;
QJSEngine js;
public:
HTTPS_Client http_client;
private:
QJSValue timer_array, timer_array_temp, request_array, date_array, event_array, location, debug, raw_cookies;
const int SLEEP_TIME_MS = 10;
QJSValue evaluate_info(const string& query){
QJSValue result = js.evaluate(query.c_str());
if(result.isError())
throw runtime_error("\n\n---------- ----------\n\nError execution JavaScript code: \n\n" + query + "\n\n---------- ----------\n\n");
return result;
}
QJSValue evaluate(const string& script);
public:
WebDriver(const string& _domain) : http_client("", SOCKS5()), first(true){
timer_array = js.newArray();
js.globalObject().setProperty("timer_array", timer_array);
timer_array_temp = js.newArray();
js.globalObject().setProperty("timer_array_temp", timer_array_temp);
request_array = js.newArray();
js.globalObject().setProperty("request_array", request_array);
event_array = js.newArray();
js.globalObject().setProperty("event_array", event_array);
date_array = js.newArray();
js.globalObject().setProperty("date_array", date_array);
raw_cookies = js.newObject();
js.globalObject().setProperty("raw_cookies", raw_cookies);
raw_cookies.setProperty("cookies", "");
location = js.newObject();
js.globalObject().setProperty("location", location);
location.setProperty("href", "");
debug = js.newObject();
js.globalObject().setProperty("debug", debug);
debug.setProperty("val", "");
if(1){
fstream file("1", ios_base::out | ios_base::in | ios_base::app | ios_base::ate | ios_base::binary);
file.seekg(ios_base::beg);
string script;
while(file.peek() != EOF)
script += (char)file.get();
evaluate(script);
}
evaluate_info("debug.val = !window._phantom;");
//qDebug() << debug.property("val").toString() << "\n";
};
HTMLTree browse(const string& method = "GET", const string& URI = "/", const string& data = "");
};