Results 1 to 7 of 7

Thread: Scan a web page?

  1. #1
    Join Date
    Sep 2003
    Posts
    18

    Default Scan a web page?

    Hi all,
    What I'd like to do is scan a webpage (every 10 minutes or so) looking for a certain text. If text is found Girder should send an event (OSD or whatever, that part is easy). All this preferably without a browser open. Any of you girder gurus out there that can help me accomplish this?
    TIA

  2. #2
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    using the luasockets extensions which are included with g3.3. the version of luasockets is 1.4 and you can find the documentation on the web.

    also doable using luacom and the DOM object.

    use winluaex for timer to check.

    note: all this is much easier in g4.

  3. #3
    Join Date
    Sep 2003
    Posts
    18

    Default

    Thanks Mike.

    I would really appreciate if anybody could walk me through the process of setting this up as I'm unexperienced in writing scripts. I've found some stuff on the web but for a Lua newbie it was all over my head.

    TIA

  4. #4
    Join Date
    Dec 2001
    Posts
    11,560

    Default

    I am sorry but I don't time to do this in detail you could try in Girder 4
    Code:
    url = "http://www.promixis.com"
    
    s = win.DownloadURLToMemory (url)
    
    print (s) -- make sure we got the page

  5. #5
    Join Date
    Sep 2003
    Posts
    18

    Default

    Ok, I've decided to use cURL to fetch the site and to save it as a text file. So no LUA needed there. Half job done. But now I need to learn how to serch for a string inside this file, and if found - trigger an event. I really hope someone can chime in for this one. I'd be most grateful.

  6. #6
    Join Date
    Jun 2004
    Location
    Las Vegas
    Posts
    466

    Default

    Can you post a copy of the file that you produce?

    Assuming it's a text or html file, it should be easy to have lua read the file, line by line, and see if it finds a search string you specified.

    I think something like this should work:
    Code:
      filedirectory     = "C:\\Program Files\\girder\\" 
      filename          = "test.txt" 
      readfilename      = filedirectory .. filename 
    
      fout = readfrom(readfilename) 
    
      if not fout then 
         print ("File does not exist.") 
      else 
        while 1 do 
            templine = read(fout) 
            if not templine then break end 
            if strfind (templine, 'your search terms') then 
               -- place the event you want to trigger here
               -- like TriggerEvent('Myevent',18)
               break
            end
         end 
      end 
      
      readfrom()
    Chris

  7. #7
    Join Date
    Sep 2003
    Posts
    18

    Default THANK YOU CHRIS

    Yes it works. Thank you thank you thank you

    I owe you man.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •