4 Replies Latest reply on Feb 5, 2014 8:20 PM by hjvanes

    Obtain infor from html and check values to compare

    hjvanes

      dear Filemake PPL,

       

      I was wondering is there a way to ctmompare and check off values from a website to a value stored in a sollution.

       

      That is my solition will have a values such as 102-103 as an example.

       

      The website html will store values after

      <html>

      102-101

      102-102

      102-103

      102-104

      102-15

      </html>

       

       

      The idea is for the solution to do a check I believe maybe with webviewwer all before </html> and a loop thorugh the values. I do know how I can do this if there were only one value stored in the html and compare.

       

      Set webviewer [object name.....

      set variable [$html ; value getlayoutobjectattribute (VW ; "Content")]

      Set variable [web$; value: Let ( [t1 = "<body>" ;t2 = "</body>" ;p1 = Position ( $HTML ; t1 ; 1 ; 1 ) ;p2 = Position ( $HTML ; t2 ; 1 ; 1 ) ;HTML = Middle ( $HTML ; p1 + Length ( t1 ) ; p2 - p1 - Length ( t1 ) )] ; Filter ( HTML ; "-0123456789" ))

      Set variable [$local; value: "102-103"

      set variable [$message;value (Isempty($web); "problem with web"; $web =$local; "No problem"; " Number is not inrecords"

      Show Custom Dialog ["Message"; $messsage]

       

      This I know would work if only one number existed between <html> and </html>.

       

      How Can I go about it that it would loop th

       

       

       

      I am not sure how I would script it to loop through every line and p[erform a check against my $local variable as it were to provide a message.

       

      Any person have any advice for me on this please or what I would need to change. Thank you in advance and much appreciated for any replies.

       

      regards,

      HJ

        • 1. Re: Obtain infor from html and check values to compare
          erolst

          Haven't looked in detail at your HTML scraping code, but it looks reasonable; assuming that that gives you a list of values, either use a loop …

           

          If [ IsEmpty ( $web ) ]

            Set Variable [ $message ; "Web problem" ]

          Else

            Loop

              Set Variable [ $i ; $i + 1 ]

              Set Variable [ $currentline ; GetValue ( $web ; $i ) ]

               Set Variable [ $found ; $found + ( $currentLine = $local ) ]

              Exit Loop if [ $found or $i = ValueCount ( $web ) ]

            End Loop

             Set Variable [ $message ; Case ( $found ; "No problem" ; "Not in list" ) ]

          End If

           

          … or try:

           

          Set Variable [ $message ; Case ( IsEmpty ( $web ) ; "Web problem" ; PatternCount ( ¶ & $web & ¶ ; ¶ & $local & ¶ ) ; "No problem" ; "Not in list" )

          • 2. Re: Obtain infor from html and check values to compare
            hjvanes

            Erolst,

             

            I have attempted it no luck. I get the mesasge that the number is not in the list when in actual fact it is.

             

            I have attached a link to sample fmp12 I quickly put together to test. I changed the $local vairable to include alpha characters as well along with the filter.

             

             

            removed

             

            Do not understand why it cannot find the value.

             

            regards,

            HJ

            • 3. Re: Obtain infor from html and check values to compare
              TimGriffith

              Why not do a 'PatternCount ( $webText ; "102-103" )'? That way you do not have to check line by line at all.

              • 4. Re: Obtain infor from html and check values to compare
                hjvanes

                Ok I discovered what the probleme was with  ( ¶ & $web & ¶ ; ¶ & $local & ¶ )

                 

                I amended this to  ( ¶ & $web & ¶ ; $local ) given that the local value does not need to paragraph in a loop.

                 

                However, I did notice that the WEB Viewer does need to have its Cache refreshed else it will continue to store old values until new refresh.  So did set the webviewer as a reload.

                 

                 

                 

                 

                Thanks again for your script Erolst.

                 

                 

                Tim,

                Your answer helped me get to the bottom of what was wrong with the script.  So thank you as well.  It does make sense and I will give that a shot now to see if it makes it easier.  Appreciate it.

                 

                regards,

                HJ