okay that's awesome if you look into it.It calls 3 js
http://cache.virtualtourist.com/js/MP1.1.7_all.js
http://members.virtualtourist.com/dwr/engine.js
http://members.virtualtourist.com/dwr/interface/AjaxServlet.js
I'm guessing the captcha/random numbers is coming from one of those. I'll take a closer look later.
why can't you just scrape the number off the page?
your browser is updating in live time for some reason my browser and curl won't do that.uhm they are to me..
<span id="cu">24670</span>
edit: I'm being told python can via beautiful soap or something.hmm, could parse the javascript in python or something. not sure about curl though.
your browser is updating in live time for some reason my browser and curl won't do that.
edit: I'm being told python can via beautiful soap or something.
I don't have a problem getting the source, I just can't track down where the JS is updating the the span with a random number...Browsers, e.g., Firefox, do not always display the entire source when viewing page source. Similarly, when you save source that you are viewing, you may not get the entire page source. This can cause you to chase your tail until you figure out this 'feature'.
Curl will get the entire source. Just run it from the command line and save source to a file. Edit/view the file, and you should see all the JS, including the included js files.
I've done a good bit of research on the subject, and Python + javascript for this purpose is a tough nut to crack.
If you haven't done so already, you really ought to check out Selenium. It gives you full access to the javascript in a page and even offers a debugger-like interface so you can inspect/change variables. You can even insert javascript code in to the DOM. The icing on the cake is that you can drive it from the command line, making it pretty cool for web automation tasks.
--Ma
Not by itself no. but there are ways of parsing javascript in python. Anything a browser can do, you can do it in python.
I don't have a problem getting the source, I just can't track down where the JS is updating the the span with a random number...
thanks I will try but I had no luck with firebug I guess I'll try this.Ah, I see. Get the Venkman javascript debugger for FF. Load the page. Set a breakpoint on the js function that does the randomization. When you hit the breakpoint, look at the backtrace. It will at least show you how the function got called.
--Ma
it updates automatically in a normal browser but if taken with curl or urllib it'll get the full source where it doesn't parse js.Just get the span content "cu".
/** The original page id sent from the server */
dwr.engine._origScriptSessionId = "E38EB46A656C70C10825E26A6092F8A0";
/** The session cookie name */
dwr.engine._sessionCookieName = "JSESSIONID"; // JSESSIONID
/** Is GET enabled for the benefit of Safari? */
dwr.engine._allowGetForSafariButMakeForgeryEasier = "false";
/** The script prefix to strip in the case of scriptTagProtection. */
dwr.engine._scriptTagProtection = "throw 'allowScriptTagRemoting is false.';";
/** The default path to the DWR servlet */
dwr.engine._defaultPath = "/dwr";
/** The read page id that we calculate */
dwr.engine._scriptSessionId = null;
/** The function that we use to fetch/calculate a session id */
dwr.engine._getScriptSessionId = function() {
if (dwr.engine._scriptSessionId == null) {
dwr.engine._scriptSessionId = dwr.engine._origScriptSessionId + Math.floor(Math.random() * 1000);
}
return dwr.engine._scriptSessionId;
};
$D.ready(function(){if($B.hasClass("legacySignUp")){var a=$("input[name='sow']").val();$("#cu").html(parseInt(a,16))}});
Here it is.
On line 376 of MP1.1.7_all.js you'll see this:
Code:$D.ready(function(){if($B.hasClass("legacySignUp")){var a=$("input[name='sow']").val();$("#cu").html(parseInt(a,16))}});
It's taking the value of <input name="sow" and using parseInt() to return an integer (the captcha) from that hex string.
Or I suppose it could be just fetched from the page?