-
libcurl and Javascript
After no luck with Python on this ordeal, I decided to come back to my first and favorite language to accomplish a task. I'm making a bot-type deal to access a site, and then click a button to proceed to the next page and then it exits. After a little bit of Firebugging, I found that the button uses Javascript functions defined as showSkip() skipButton(). Is there any way I can invoke javascript functions by name or just simply simulate a mouse click on that button (without wasting energy showing a browser window that is)
-
There may be some library out there to help with that kind of thing (what you are doing is called "web scraping") but I've never heard of one. The big complication is that to invoke a js function, you would (at least) need to incorporate a js interpreter, such as spidermonkey. To make that useful, you'd have to do in the context of the page, which means you are now dealing with a sort of web browser proper. I really don't think going that route is very feasible, but I could be wrong -- maybe someone has developed such a tool. A lot of people make their living with web scrapers.
Much easier, if you understand js: figure out what those js functions do; they will be defined in one of the scripts that came with the page (you can find those in firebug).
If you don't understand js, you are basically up a creek with this kind of stuff. It's fundamental, you'll have to start learning. Create a simple web page, source a script in it, start hacking.
Code:
function jshw () {
document.write("<h1>hello world</h1>");
}
function jshwDOM () {
var eg = document.createElement('h1');
eg.innerHTML = "hello world"
document.body.appendChild(eg);
}
If you can explain exactly what it is you are trying to do and/or post those functions, I might be able to give you a hint (altho, I'm going offline soon).
-
I do know some Javascript but the incorporating is what I'm having trouble with
Code:
function showSkip() { skip_ad2 = true;
_.G("please_wait").style.display = 'none';
_.G("skip_button").style.display = '';
}
function skipButton() {
skip_button_clicked = 1;
_.X("/l.php",function(response){},"user=1225338&user2=1225338<=" + log_token)
return false;
Those are the functions. It's an adf.ly bot and needs to connect by proxy to work. Even through Python, you could open the page with urllib2 but you can't use a Javascript function from PyV8 or pydermonkey from the page.
-
So, if I'm reading this correctly, you're looking to scam adf.ly?
-
Not really. It's no different from anyone else clicking on their ads. They still get paid for it.
-
Can you show the function _.X()? Also, what site is it that you're accessing?
-