Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function getQRZSession(login, password)
- {
- // Retrieve stage 1 login tokens
- var xhr = new ActiveXObject("Msxml2.XMLHTTP");
- xhr.open("GET","http://www.qrz.com/",false);
- xhr.send(null);
- var content = xhr.responseText;
- var action = "";
- if (!/<form id="cmdbar" action="(\/li\/[0-9]+)" m/.test(content))
- {
- return false;
- }
- action = RegExp.$1;
- var refr = action;
- // Retrieve stage 2 login tokens
- xhr.open("POST","http://www.qrz.com" + action, false);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send('refr=/&refcs=&cmdLogin=Login');
- content = xhr.responseText.replace(/\n/g, " ");
- if (!/<form name="loginform" action="(\/li\/[0-9]+)" .* name="s" value="([a-z0-9]+)"/.test(content))
- {
- return false;
- }
- action = RegExp.$1;
- var s = RegExp.$2;
- // Log in
- xhr.open("POST","http://www.qrz.com" + action, false);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send('refr=' + refr + '&s=' + s + '&username=' + login + '&password=' + password);
- content = xhr.responseText;
- if (!/Login Success/.test(content))
- {
- return false;
- }
- return true;
- }
- function getQRZInfo(callSign, login, password)
- {
- var xhr = new ActiveXObject("Msxml2.XMLHTTP");
- xhr.open("POST","http://www.qrz.com/db/",false);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send("callsign=" + escape(callSign));
- var content = xhr.responseText.replace(/\n/g, " ");
- if (/produced no results/.test(content))
- {
- return "No results";
- }
- if (/Login is required for additional detail/.test(content))
- {
- if (!getQRZSession(login, password))
- {
- return "Cannot login to QRZ.com";
- }
- xhr.open("POST","http://www.qrz.com/db/",false);
- xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
- xhr.send("callsign=" + escape(callSign));
- content = xhr.responseText.replace(/\n/g, " ");
- }
- if (!/"Click for Mailing Label">(.*)<b>Lookups: [0-9]+<\/b>/.test(content))
- { WScript.Echo(content);
- return "QRZ returned an unexpected result";
- }
- var address = RegExp.$1.replace(/ /g, "").replace(/<.+?>/g, "");
- var born = RegExp.$2;
- return address;
- }
- WScript.Echo(getQRZInfo("c4ll", "login", "password"));
Add Comment
Please, Sign In to add comment