Computer Science Canada

How can I open an URL using Turing? What command do I use?

Author:  Linksku [ Fri May 06, 2011 6:57 pm ]
Post subject:  How can I open an URL using Turing? What command do I use?

What is it you are trying to achieve?
Open a URL (not display or read it). I want to use Facebook's Graph API with Turing. It's possible as long as I can connect to Facebook.


What is the problem you are having?
Don't know what command to use.


Describe what you have tried to solve this problem
I tried Net.OpenURLConnection, but it freezes Turing (Windows 7 64 bit/Turing 4.1.1)


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)

Turing:

var url : string
put "Enter the URL to load: " ..
get url

var netStream : int
var line : string

netStream := Net.OpenURLConnection (url)
if netStream <= 0 then
    put "Unable to connect to ", url
    return
end if
loop
    exit when eof (netStream)
    get : netStream, line
    put line
end loop
Net.CloseConnection (netStream)


Please specify what version of Turing you are using
4.1.1

Author:  apython1992 [ Fri May 06, 2011 8:38 pm ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

Works just fine with Turing 4.1. I tried it on 64-bit Windows. Perhaps install Turing 4.1.

Author:  Linksku [ Mon May 09, 2011 4:22 pm ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

Thanks, that worked. Why doesn't 4.1.1 work? My school and my teacher both use 4.1.1

Author:  ProgrammingFun [ Mon May 09, 2011 8:17 pm ]
Post subject:  Re: RE:How can I open an URL using Turing? What command do I use?

Linksku @ Mon May 09, 2011 4:22 pm wrote:
Thanks, that worked. Why doesn't 4.1.1 work? My school and my teacher both use 4.1.1

Because 4.1.1 was unfinished when Holtsoft (creator) started dying...so it is quite buggy and apparently, the source code for Turing is a mess....

Author:  goroyoshi [ Mon May 09, 2011 8:25 pm ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

Can't you also use Sys.Exec
Sorry for necroposting

Author:  Tony [ Mon May 09, 2011 8:31 pm ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

Presumably the intent is to read (in program) the contents of the page, not simply tell a browser to open it.

Quote:

when Holtsoft (creator) started dying

What? Did you mean Dr. Holt (I'm pretty sure that I've seen him on campus after the release), or Holtsoft the company (which was dissolved, seemingly due to unprofitability)?

Author:  mirhagk [ Tue May 10, 2011 7:48 am ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

and I'm sorry but is the Turing source code available?

Author:  Tony [ Tue May 10, 2011 9:07 am ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

We've asked, but no.

Author:  mirhagk [ Tue May 10, 2011 10:52 am ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

Okay that's what I thought, but ProgrammingFun's post seemed to suggest otherwise.

I remember actually contacting Dr. Holt about getting the source, he told me a lot about it, but never responded to my request for the source code.

Author:  Linksku [ Wed May 11, 2011 6:16 pm ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

I try about 20 websites using the code that I posted above and 4.1. All of them returned an error of some sort.

Only http://localhost/ works. I tried running Apache, and Turing fetched the contents of localhost correctly.

Author:  Tony [ Wed May 11, 2011 6:23 pm ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

Might be a problem with firewall rules.

Author:  Linksku [ Wed May 11, 2011 10:15 pm ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

My firewall has exceptions for Turing. Each website has a different message. For google.com, it returns 302 but it says "The document has moved <a href="http://google.com">here</a>."

I tried entering the website's IP directly, the same thing happened.

Author:  Tony [ Wed May 11, 2011 10:27 pm ]
Post subject:  RE:How can I open an URL using Turing? What command do I use?

Ohhh! Yes. You are supposed to follow the 3xx redirects.
Quote:

tony$ curl --head google.com
HTTP/1.1 301 Moved Permanently
Location: http://www.google.com/

tony$ curl --head www.google.com
HTTP/1.1 302 Found
Location: http://www.google.ca/

tony$ curl --head www.google.ca
HTTP/1.1 200 OK


: