What happened to the Messenger Plus! forums on msghelp.net?
Shoutbox » MsgHelp Archive » Messenger Plus! for Live Messenger » Scripting » [Help] Searching pages

Pages: (2): « First [ 1 ] 2 » Last »
[Help] Searching pages
Author: Message:
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. [Help] Searching pages
Hello.

I'm sure this has been asked before, but I did a search and didn't find anything close to this..

Is it possible to make a script search a website, and return the results into a var (used for checking for certain text)?

An example would be searching the main page of my site, returning the results of all the text found on the main page, finding the first instance of Update, then seeing what 3 chars after it are.


-Paril
08-11-2006 12:57 PM
Profile E-Mail PM Web Find Quote Report
RaceProUK
Elite Member
*****

Avatar

Posts: 6073
Reputation: 57
39 / Male / Flag
Joined: Oct 2003
RE: [Help] Searching pages
I imagine it's possible, since JScript can deal with XML stuff, but that would mean the webpage has to be valid XHTML.

Other than that, you could use some regular expressions to fetch only what you need from the page.
[Image: spartaafk.png]
08-11-2006 03:35 PM
Profile PM Web Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: [Help] Searching pages
Could ya help me on that?
Maybe on MSN we can discuss this?
08-11-2006 03:37 PM
Profile E-Mail PM Web Find Quote Report
AberNStein
Full Member
***


Posts: 132
Reputation: 2
Joined: Jul 2006
RE: [Help] Searching pages
i've got a script doing pretty much that. i had a thread about it a while ago.

the checkdupe(datum) function checks whether the given input is in the logfile (returns true or false), and the logging(datum) saves the given input to the logfile
getdata() reads the given website, and then calls parseTt(htmls).
in my script, parseIt iterates through all the links in the page, then for each one with "[release]" in the link's innerHTML that isn't already in the logfile, it pops up a toast. then it adds it to the logfile. pretty straightforward really.

oh and the script might give you a runtime error. ignore it.

right now it just goes when i start up messenger but it wouldn't be hard to make it go every 10 mins or whatever. just call getData();

code:
function OnEvent_Initialize(MessengerStart) {
}

var TheFile = MsgPlus.ScriptFilesPath + "\\log.txt";
var fso = new ActiveXObject("Scripting.FileSystemObject");
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

getData();

function checkDupe(datum) {
if(fso.FileExists(TheFile)) {
var a = fso.OpenTextFile(TheFile, 1);
var text = a.ReadAll();
text = text.split('\r\n');
for(var i = 0;i<text.length;i++)
if(text[i] == datum) {
a.Close();
return true;
}
a.Close();
return false;
}
}
function logging(datum) {
if(fso.FileExists(TheFile)) {
if(checkDupe(datum))
return;
a = fso.OpenTextFile(TheFile, 8);
} else
var a = fso.OpenTextFile(TheFile,2,true);
a.WriteLine(datum);
a.Close();
}

function getData() {
xmlhttp.open("GET", "http://shoutbox.menthix.net/forumdisplay.php?fid=39", true);
xmlhttp.onreadystatechange = stateChanged;
xmlhttp.send(null);
}

function stateChanged() {
if (xmlhttp.readyState==4)
if (xmlhttp.status==200)
   parseIt(xmlhttp.responseText);
}

function parseIt(htmls)
{
var foo = "";
var oDoc = new ActiveXObject("htmlfile");
oDoc.open();
oDoc.write(htmls);
oDoc.close();
var links = oDoc.getElementsByTagName("a");
for (var i=0; i<links.length; i++) {
foo = links[i].innerHTML.toLowerCase()
if (foo.indexOf("[release]") > -1 && !checkDupe(links[i].innerHTML)) {
MsgPlus.DisplayToast("MsgHelp.net [Release]",links[i].innerHTML,'','OpenSite',links[i].HREF);
logging(links[i].innerHTML);
}
}
}

function OpenSite(url) {
new ActiveXObject('WScript.Shell').run('http://shoutbox.menthix.net/' + url);
}

function OnEvent_Uninitialize(MessengerExit) {
}

edit: for some reason OpenSite(url) isn't working properly. i'd much appreciate it if someone could go over my code and improve it. if not, i'll fix it when i get back (i'm going away for two weeks).

This post was edited on 08-11-2006 at 04:58 PM by AberNStein.
[Image: gybouserbar6hc.gif]
08-11-2006 04:34 PM
Profile PM Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: [Help] Searching pages
..It'll be called when you type a command, I can't see why I would want it to be automatic, it would be annoying to everyone that I have a window open with.

It should just return all of the text on the page into a var or char, then I'll be checking that var for a certain string, then returning an int.
08-11-2006 05:22 PM
Profile E-Mail PM Web Find Quote Report
Paril
Junior Member
**

Avatar
Admin of Paril's Projects

Posts: 69
31 / Male / Flag
Joined: Jul 2006
O.P. RE: [Help] Searching pages
No one has a solution?
08-11-2006 08:19 PM
Profile E-Mail PM Web Find Quote Report
AberNStein
Full Member
***


Posts: 132
Reputation: 2
Joined: Jul 2006
RE: [Help] Searching pages
well you could modify my code
that's why i posted it.

code:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
var YourSite = "http://www.example.com";
var YourData = "";

function getData() {
xmlhttp.open("GET", YourSite, true);
xmlhttp.onreadystatechange = stateChanged;
xmlhttp.send(null);
}

function stateChanged() {
if (xmlhttp.readyState==4)
if (xmlhttp.status==200)
  YourData = xmlhttp.responseText;
}



that's just the bit that grabs the page and puts it into a variable.
you sound like you can parse it yourself.

This post was edited on 08-11-2006 at 09:47 PM by AberNStein.
[Image: gybouserbar6hc.gif]
08-11-2006 09:21 PM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: [Help] Searching pages
Wouldn't:

code:
var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");

function getIt(url) {
   xmlhttp.open("GET", url, true);
   xmlhttp.onreadystatechange = stateChanged;
   xmlhttp.send(null);
}

function stateChanged() {
if (xmlhttp.readyState==4)
if (xmlhttp.status==200)
   var thevar = xmlhttp.responseText;
   // Do here what you like with the var
}

do the trick?*-)
08-11-2006 09:23 PM
Profile E-Mail PM Find Quote Report
AberNStein
Full Member
***


Posts: 132
Reputation: 2
Joined: Jul 2006
RE: [Help] Searching pages
lol i just edited my post to pretty much exactly that
edit: actually can variables that are declared within functions be used elsewhere? i'm not quite sure.

This post was edited on 08-11-2006 at 09:28 PM by AberNStein.
[Image: gybouserbar6hc.gif]
08-11-2006 09:27 PM
Profile PM Find Quote Report
J-Thread
Full Member
***

Avatar

Posts: 467
Reputation: 8
– / Male / –
Joined: Jul 2004
RE: [Help] Searching pages
Globally variables can...

You can do:

code:
var bla;

function a() {
  // Do something
  bla = "hello";
  b();
}

function b() {
  alert(bla);
}

but not:

code:
function a() {
  // Do something
  var bla = "hello";
  b();
}

function b() {
  alert(bla);
}
08-11-2006 09:38 PM
Profile E-Mail PM Find Quote Report
Pages: (2): « First [ 1 ] 2 » Last »
« Next Oldest Return to Top Next Newest »


Threaded Mode | Linear Mode
View a Printable Version
Send this Thread to a Friend
Subscribe | Add to Favorites
Rate This Thread:

Forum Jump:

Forum Rules:
You cannot post new threads
You cannot post replies
You cannot post attachments
You can edit your posts
HTML is Off
myCode is On
Smilies are On
[img] Code is On