I'm trying to reimplement getting captcha inside c# application. Having problem, because of no experience in JS.
GET-request returns data, which contains captcha src tag, empty by default.
...
<div class="context"><img src="" id="capchaVisual" alt="loading..."></div>
...
It also returns some javascript, that fills captcha, like this:
function() {
var h = window.location.href;
if (h.indexOf("mytag") + 1) {
var scr = $("#capchaVisual").attr("src");
$("#capchaVisual").attr("src", scr + "data:image/jpeg;base64,/9j/MYCAPTCHADECODED...");
}
My steps in c# application:
- Load json with data and scripts via WebClient and JavaScriptSerializer. Done. Result stored in jsonobject answer, where answer.data contains html, and answer.e - scripts to execute.
Try to execute loaded scripts via Jurassic:
var engine = new Jurassic.ScriptEngine(); engine.EnableDebugging = true; //engine.SetGlobalValue("window", answer.data); foreach (var line in answer.e) { var evalresult = engine.Evaluate(line); string t = evalresult.ToString(); }
Failed with: ReferenceError: window is not defined.
If uncomment line 3engine.SetGlobalValue("window", answer.data)
, get anotwer error: TypeError: undefined cannot be converted to an object.
Found an answer in old Jurassic issues. My scripts uses DOM window object, but:
paulbartrum Jan 26, 2011 at 11:01 AM