9 Replies Latest reply on Sep 22, 2007 10:48 PM by BKBK

    Can I do this in coldfusion?

    SilentBob'secretfusion Level 1
      Hi all. I need to do the following
      1. Log into a website
      2. click a link
      3 download a file by clicking a button (and accepting the file download in the pop up)

      Can I do this in coldfusion?

        • 1. Re: Can I do this in coldfusion?
          Grizzly9279 Level 1
          In theory yes, but it's not easy.

          Speaking at a high level, you'll need to do the following:
          1) CFHTTP POST your login credentials.
          2) Analyze response for successful/unsuccessful login
          3) If unsuccessful login, abort with error message
          4) If successful login, capture cookie/state variables returned
          5) If you know what the address of the file to download is going to be ahead of time, use CFHTTP GET (passing along all cookie/state vars explicitely) to retrieve the file and save it to disk on the CF-server

          **If the address of the file to download is dynamic, you can try using CFHTTP GET to retrieve the raw HTML of the page that displays the "link" in question, and you can then use regular expression searches to locate and discover the address of the file you want to download.

          I hope this helps.
          • 2. Re: Can I do this in coldfusion?
            Level 7
            Are you talking about building a website where users can login and
            download files you are hosting with the site?

            This is trivial and the only part that would require actual CFML code is
            the login verification. Everything else could technically be straight HTML.


            Or are you asking how to use ColdFusion to login to another site and
            download files from the remote site to the CF server.

            That is the process Grizzly described.
            • 3. Re: Can I do this in coldfusion?
              SilentBob'secretfusion Level 1
              No... What I mean is can I create an application in coldfusion that doest the following:

              1. Logs into a website (for example www.needreport.com)
              2. Provides login credentials upon request of www.needreport.com
              3. After login happens, the coldfusion application will click a link imbedded in www.needreport.com.


              Basically, I need to create an application which acts like a user using a browser.

              Can this be done in coldfusion, if not, does any know of an application or a language which do this?
              • 4. Re: Can I do this in coldfusion?
                SilentBob'secretfusion Level 1
                Hmmm. This forum is acting funky this morning. Messages appearing and disappearing.

                Anyway, to be honest. I am alittle lazy and don't really want to code all this. Do applications exist which can capture the users actions, record them, then repeat them when required.
                • 5. Re: Can I do this in coldfusion?
                  aredovian Level 1
                  C++ or Visual Basic would be much better langauges for this type of application. I'm sure there are applications doing this already but you might need to do some deep searching, however, instructions on how to do this are really easy to find. Here is one link that explains how to do it...

                  http://dn.codegear.com/article/30197
                  • 6. Re: Can I do this in coldfusion?
                    BKBK Adobe Community Professional & MVP
                    1. Logs into a website (for example www.needreport.com)
                    2. Provides login credentials upon request of www.needreport.com


                    <cfhttp url=" http://www.needreport.com/login.cfm" method="post">
                    <cfhttpparam name="username" type="FormField" value="me_myself">
                    <cfhttpparam name="password" type="FormField" value="1243">
                    </cfhttp>

                    3. download a file

                    <cfhttp method="Get" url=" http://www.needreport.com/downloadPage.cfm" throwOnError="Yes" />

                    We assume the download file is embedded in downloadpage.cfm by means of the combination cfheader/cfcontent. In this way the host server could arrange a login and download session for you.







                    • 7. Re: Can I do this in coldfusion?
                      BKBK Adobe Community Professional & MVP
                      Hmmm... I spoke too quick. When I got down to testing it I found that i could only download text files in this manner. Binaries give encoding problems. Will look into it some other time. Not feeling too well.


                      • 8. Re: Can I do this in coldfusion?
                        Grizzly9279 Level 1
                        quote:

                        Originally posted by: SilentBob'secretfusion
                        Hmmm. This forum is acting funky this morning. Messages appearing and disappearing.

                        Anyway, to be honest. I am alittle lazy and don't really want to code all this. Do applications exist which can capture the users actions, record them, then repeat them when required.



                        JMeter ( http://jakarta.apache.org/jmeter/ ) can actually do exactly what you're asking for. With Jmeter, you can "record" a user's session clicking around a web site, and you can save it to a "test plan". You can then re-run that "test plan" over and over again. You can also configure it to run multiple "threads" (users) performing those actions at the same time.

                        This tool often comes in handy for performance and load testing, but can be used for a variety of other purposes.
                        • 9. Can I do this in coldfusion?
                          BKBK Adobe Community Professional & MVP
                          Back to my last post as promised. My first experiment with downloading binaries using cfhttp in that way led to an encoding problem.

                          However, I have solved it. I simply applied the functions toBinary and toBase64.