Interesting question about reading .html files to find information

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts
  • drougnor
    Forum Member
    • Dec 2005
    • 7

    Interesting question about reading .html files to find information

    I'm working on a project to do an installation for the Folding @ Home program's Console Only client. Their License strictly forbids the distributing of their software, so I'm trying to figure a way to have the installer download the core to the client computer for setup. The obvious method is to use a static address, but if they change versions of the software, I'll have to recompile to keep up.

    My question is this: Another person doing a similar project using a different utility had his setup program open the .html file found here (http://folding.stanford.edu/download.html) and read until it found the first instance of "No Nonsense". Once it finds this, he then had it read the first full address that contained a .exe file. Is there any way to replicate this in Setup Factory?

    If so, can I get an example of the process?

    Thanks!

    D
  • Adam
    Indigo Rose Staff Member
    • May 2000
    • 2149

    #2
    It should be possible with some fancy scripting. Sorry I don't have a pre made sample script ready but the concept would be:

    - Download the .html file using HTTP.Download()
    - Read the contents of the file to something that SUF can work with using: TextFile.ReadtToString() or TextFile.ReadToTable().
    - use a loop to traverse the entire file.
    - use String.___() actions to look for the pattern ect.

    Maybe once you get some code going I can help.

    Adam Kapilik

    Comment

    • drougnor
      Forum Member
      • Dec 2005
      • 7

      #3
      Originally posted by Adam
      It should be possible with some fancy scripting. Sorry I don't have a pre made sample script ready but the concept would be:

      - Download the .html file using HTTP.Download()
      - Read the contents of the file to something that SUF can work with using: TextFile.ReadtToString() or TextFile.ReadToTable().
      - use a loop to traverse the entire file.
      - use String.___() actions to look for the pattern ect.

      Maybe once you get some code going I can help.

      Adam Kapilik
      Ok, I'm studying up on the string manipulation code as well as comparing functions that SF uses compared to the NSIS code that I'm trying to emulate and have started to put together some psuedo code . . . But, am kinda stuck on the actual retrieval of the dowload target.

      I'm going to download the .html file, read it into a table and do a find to search for the first instance of 'Console.exe'. This will point to the end of the a href line that targets the downloadable .exe file. where I'm getting stuck is "How am I going to find the start of that line logically and tell the system to ONLY copy from 'http:' to '.exe'

      The chunk of the .html file that I'm using as the reference to design this is as follows.

      <tr bgcolor="#E0E0E0">
      <td width="370"><font face="Arial, Helvetica, sans-serif"> Windows
      NT/2000/XP <br>"No nonsense" text-only console <font size=-1>(with built-in Windows-service-install option)</font></font></td>
      <td width="10"><font face="Arial, Helvetica, sans-serif"><a href="winchanges.txt">5.04beta</a><img src="new2.gif" width="28" height="11"> </font></td>
      <td width="64"><div align="center"><font face="Arial, Helvetica, sans-serif"> <b><a href="http://www.stanford.edu/group/pandegroup/release/FAH504-Console.exe"><img src="windows.gif" width="75" height="61" border="0" align="baseline"></a></b><br>
      <a href=http://www.stanford.edu/group/pandegroup/release/FAH504-Console.exe>download </a></font></div></td>
      <td width="68"><font face="Arial, Helvetica, sans-serif"> <a href="console-userguide.html">Console info</a></font></td>
      <td width="67"><font face="Arial, Helvetica, sans-serif"> <a href=license.txt>
      License </a> </font></td>
      <td width="150"><font face="Arial, Helvetica, sans-serif"> <font size = -1>51268b890d4e35437667ae6186640158</font></font></td>
      This is where I'm getting hung up, and as I said, it's only the Psuedo coding phase . . . I guess I'm going to just put some test code together and see what falls out when I start shaking the tree.

      Comment

      • drougnor
        Forum Member
        • Dec 2005
        • 7

        #4
        I'm slowly figuring this out . . . doing this at work, so it's taking me some time bouncing back and forth . . . but so far I have a loop that will read the table until it hits the line that has the 'No nonsense' line. I then use the value generated by the first String.Find as a starting point to search for the first http. I then find the first Console.exe using the same starting point to create the range where the address resides. . . Now, just gotta do some String.Mid testing to get the right combo . . .

        I'll fill you in when I hit paydirt.

        Comment

        • drougnor
          Forum Member
          • Dec 2005
          • 7

          #5
          Man, that's annoying . . . not being able to edit a post after 15 minutes . . . But, hey, I guess it's what the admin wants . . .

          So, I did it! Success!! The code I used is this (Mind, I used a local copy of the .html file for now.)

          --Set control variable condition
          notfound = false
          --read the html file into a table.
          text_contents = TextFile.ReadToTable("C:\\temp\\download.html");
          --set the count variable to initial condition.
          ncount = 0
          --create the test loop
          while notfound == false do
          ncount = ncount + 1
          strfound = String.Find(text_contents[ncount], "No nonsense", 1, true);
          --tests to see if the string was found
          if strfound ~= -1 then
          --kicks back exit condition to break the loop
          notfound = true;
          end
          end
          --get the start and a close to end value using the initial found string as a starting point
          str2ndtest = String.Find(text_contents[ncount], "http", strfound, true);
          str3rdtest = String.Find(text_contents[ncount], ".exe", strfound, true);
          --do the calculation to get the string length (add four to account for the .exe search not truely showing the end of the string)
          strEnd = str3rdtest + 4
          strLength = strEnd - str2ndtest
          str4thtest = String.Mid(text_contents[ncount], 6222, strLength)
          --display results so I know if I've got it right
          strDisplay = Dialog.Message("Result", "The line is "..ncount..", and the control search value is "..strfound..".\r\nThe start is "..str2ndtest.." and the end is "..strEnd..".\r\nThe address is "..str4thtest..".", MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
          So, if you have any suggestions on how to trim this down to make it more streamlined, my ears are open, as I'm sure this is pretty brute force . . .

          Thanks a ton for helping me find a starting place!

          Comment

          • willfreer
            Forum Member
            • Aug 2004
            • 47

            #6
            html controlling autoplay?

            Hi guys, trying to figure out if this is possible. I have an autoplay project starting up with an webpage in the webobject.

            It also has narration on it. I would like the narration to stop when anything is click in the webpage. and if that is someway possible. Can it be restarted with an Replay Narration link in the Web page?

            I saw some links in flash that showed how to used flash buttons to control autoplay actions, just wondering can it be done in html.

            Thanks

            Will

            Comment

            Working...
            X