6 Replies Latest reply on Aug 9, 2012 7:02 PM by guy@guym.com

    Hoe to Capture data from web view

    guy@guym.com

      I'd like to script capturing a picture from a web view window and save it to disk.

       

      Easy to do manually via right click and save image; but with hundreds of records, needs to be scripted.

       

      Any clues?

       

      Guy

        • 1. Re: Hoe to Capture data from web view
          nsabel

          This can get complicated and become un reliable, but its possible. First you need to pull apart the source code from the web viewer and build a URL to the image file. Next your script will use the URL in the Insert from URL script step to put the image in a container field. If you want the file saved to the desktop or elsewhere just export the container contents.

           

          For parsing the HTML code I use this custom function:

           

          // ParseData ( theText; theStartTag; theEndTag; theOccurance)

          //

          // Extract the text between two strings.

          //

          // Parameters:

          // theText = the text to parse

          // theStartTag = the string that comes before the text to extract

          // theEndTag = the string that comes after the text to extract

          // theOccurance = the instance of the text to extract

          //

          // Return Value:

          // the instance of text found in theText beween theStartTag and theEndTag based on theOccurance

          //

           

           

          Let ( [

           

           

          theStartPos = Position ( theText ; theStartTag ; 1 ; theOccurance ) ;

          theResult = Case (

           

           

           

           

          // ------------------------------

          // If theStartTag was not found, return an empty string.

          theStartPos = 0 ; "" ;

          // ------------------------------

           

           

           

           

          // ------------------------------

          // If theStartTag was found, get the string we are looking for.

          theStartPos > 0 ;

          Let ( [

          theStartPos = theStartPos + Length ( theStartTag ) ;

          theEndPos = Position ( theText ; theEndTag ; theStartPos ; 1 ) ;

          theLengthToKeep = theEndPos - theStartPos;

          theResult = Middle ( theText ; theStartPos ; theLengthToKeep )

          ] ;

          theResult

          )

          // ------------------------------

           

           

           

           

          ) // End case

           

           

          ] ;

           

           

          theResult

           

           

          )

           

          You will use the the following function to grab the source code from the webview.

           

          GetLayoutObjectAttribute ( "Name of Web Viewer" ; "content" ) ;

           

           

          Again this is not simple and if you dont have control over the web page it can break at any time.

           

          Nick

          • 2. Re: Hoe to Capture data from web view
            Malcolm

            Use fmp as a data source to generate the urls and pass the job to cURL.

             

            malcolm

            • 3. Re: Hoe to Capture data from web view
              guy@guym.com

              I downloaded the trial for FM 12.

               

              IN FM 12, Insert URL script step is a piece of cake.

               

              As I build the url from other info then hand off to Google maps API, I get a map image and then place it into a container field.

               

              Insert URL (url_field)

               

              url_field is built from addresses and user defined mapping variables=

              VARIABLE="http://maps.googleapis.com/maps/api/staticmap?"

              &

              "zoom=" & Assets::Map Size

              &

              "&size=592x622"

              &

              "&maptype="&Assets::Map Type

              &

              "&scale=1"

               

              & $position

              & "&sensor=false"

               

              Parsing a url to extract an image is not the issue.

               

              THANKS FOR THE RESPONSE

              • 4. Re: Hoe to Capture data from web view
                guy@guym.com

                I downloaded the trial for FM 12.

                IN FM 12, Insert URL script step is a piece of cake.

                As I build the url from other info then hand off to Google maps API, I get a map image and then place it into a container field.

                Insert URL (url_field)

                url_field is built from addresses and user defined mapping variables=

                VARIABLE="http://maps.googleapis.com/maps/api/staticmap?"

                &

                "zoom=" & Assets::Map Size

                &

                "&size=592x622"

                &

                "&maptype="&Assets::Map Type

                &

                "&scale=1"

                & $position

                & "&sensor=false"

                Parsing a url to extract an image is not the issue.

                THANKS FOR THE RESPONSE

                 

                               

                            created by nsabel in General - View the full discussion

                • 5. Re: Hoe to Capture data from web view
                  nsabel

                  My misunderstanding I didn't realize you already knew the URL. In that case yes it is quite easy and simple.

                  • 6. Re: Hoe to Capture data from web view
                    guy@guym.com

                    but not with earlier than 12... that is a new function... thankfully.