Page 1 of 1

Getting another web page

Posted: Wed Sep 26, 2007 1:06 am
by andyh1234
Just a quickie!!

Im trying to load another webpage with a cgi script, but struggling.

I want to load a page on another server, check it against a copy I have, and if its changed make a log, send an email etc.

I can do it no problem using the put url "xxx" into xxx within the Studio, but this doesnt seem to work in the cgi on the linux server, I assume before the cgi is not v2.8.x

I can do all the rest, sending the email etc.

Any ideas on how to grab another web page and put it into a buffer using the cgi???

Thanks

Andy

Posted: Wed Sep 26, 2007 1:22 am
by Mark
Hi Adny

I think this should work. Can you post your script?

Best,

Mark

Posted: Wed Sep 26, 2007 3:53 pm
by andyh1234
Sure,

A very simple script is...

---- INSIDE REVOLUTION....
on mouseup
put "Content-Type: text/plain" & cr & cr
put "Loading..."
put "http://www.google.com/" into myURL
put URL myURL into myReturn
put myReturn
end mouseup

---- ON THE SERVER
#!/usr/local/revolutioncurrent
on startup
put "Content-Type: text/plain" & cr & cr
put "Loading..."
put "http://www.google.com/" into myURL
put URL myURL into myReturn
put myReturn
end startup


Works fine inside studio, but not on the server. Studio returns all the text and the html for the page, the server just returns 'Loading...'

The path #!/usr/local/revolutioncurrent is correct on my server btw!

Thanks

Andy

Posted: Wed Sep 26, 2007 4:52 pm
by Mark
Andy,

I have tried it and at the moment I can do no more than confirm that this does't work.

I am able to open sockets to another machines from a remote web server. Depending on what you want to do exactly, that might be an alternative for you.

Best,

Mark

Posted: Wed Sep 26, 2007 5:47 pm
by andyh1234
Thanks Mark,

I figure its probably a timeout, ill try and work it out using more code or just code it in perl, just hoping it was a quick fix in revolution!

Thanks

Andy

Posted: Wed Sep 26, 2007 7:12 pm
by Mark
Andy,

I set the timeout to 20 seconds and still nothing happened. In fact, What surprises me is that I don't get an execution error, while the result is also empty after putting the url. There is not timeout error either.

Best,

Mark

Posted: Sat Sep 29, 2007 10:27 pm
by Mark Smith
I think you'd have to have libUrl available for it to work.

It's possibe to separate libUrl out from the IDE, but remember that the cgi engines are still in 'legacy', so you'd hav to put libUrl into a stack and save it in legacy format.

Then you could load it as a library in your cgi:

start using stack "libUrl.rev" (assuming you saved in the same directory as the cgi). This should work, I think.

Best,

Mark

Posted: Sat Sep 29, 2007 10:36 pm
by Mark
Mark,

I thought of that, but there is no execution error. I wonder why?

Mark

Posted: Tue Oct 02, 2007 2:09 am
by Mark Smith
I've tested this now and I'm afraid it doesn't seem to work - my guess is that libUrl is tied in to the engine (I think calls like 'get url "someUrl" go to the engine which then calls libURL, and it seems like this doesn't work with the cgi engines).

The other option is to use curl - this seems to work fine.
On OS X (which has curl installed by default), the call would be:

get shell("curl -s " & "http://www.somesite")

I'm afraid I don't know if this will be helpful on Windows.

Best,

Mark

Posted: Wed Oct 03, 2007 11:56 am
by andyh1234
My server is on Linux, so I can install Curl, thanks Mark.