Differences between revisions 1 and 10 (spanning 9 versions)
Revision 1 as of 2006-12-31 21:12:57
Size: 1123
Editor: KaiJaeger
Comment:
Revision 10 as of 2008-03-01 16:30:03
Size: 1335
Editor: KaiJaeger
Comment:
Deletions are marked like this. Additions are marked like this.
Line 1: Line 1:
## page was renamed from DotNetSamples/WebInterface
= Dealing with the Web - Requesting Pages =

Note that this example uses the new syntax introduced with Version 11. It will not run unchanged under prior versions.
Line 4: Line 9:
System∆Net∆WebRequest;⎕ML;⎕IO;htmlPage;MyWebRequest;TheResponse;MyStream;URL
⍝ Version 1.0 from 2006-12-24 ⋄ Kai Jaeger ⋄ APL Team Ltd
 System∆Net∆WebRequest;⎕ML;⎕IO;htmlPage;MyWebRequest;TheResponse;MyStream;URL
⍝ Version 1.1 from 2007-01-05 ⋄ Kai Jaeger ⋄ APL Team Ltd
Line 9: Line 14:
 URL←'http://www.google.co.uk/search?q=dyalog+apl&ie=utf-8&oe=utf-8&rls=org.mozilla:en-GB:official&client=firefox-a'  URL←'http://www.google.co.uk/search?q=dyalog+apl'
Line 27: Line 32:
⍝ End
}}}
⍝ End}}}

Author: KaiJaeger
----
CategoryDyalogExamplesDotNet

Dealing with the Web - Requesting Pages

Note that this example uses the new syntax introduced with Version 11. It will not run unchanged under prior versions.

The following code is asking Google for a search on two words: "dyalog" and "apl":

 System∆Net∆WebRequest;⎕ML;⎕IO;htmlPage;MyWebRequest;TheResponse;MyStream;URL
⍝ Version 1.1 from 2007-01-05 ⋄ Kai Jaeger ⋄ APL Team Ltd
 ⎕ML ⎕IO←1

 ⎕USING←'System,System.dll' ''
 URL←'http://www.google.co.uk/search?q=dyalog+apl'

⍝ Create a request for the URL
 MyWebRequest←System.Net.WebRequest.Create⊂URL
⍝ If required by the server,set the credentials.
 MyWebRequest.Credentials←System.Net.CredentialCache.DefaultCredentials
⍝ Get the response
 TheResponse←MyWebRequest.GetResponse
⍝ Display the status
 ⎕←TheResponse.StatusDescription
⍝ Get the stream containing content returned by the server
 MyStream←TheResponse.GetResponseStream
⍝ Open the stream using a StreamReader
 htmlPage←⎕TC[2]~⍨(System.IO.StreamReader.New MyStream).ReadToEnd
⍝ Reformat because we can't see  much otherwise
 htmlPage({⍺⊂⍨⍵=⍺})←'<'
⍝ Display what we get
 ⎕ED'htmlPage'
⍝ End

Author: KaiJaeger


CategoryDyalogExamplesDotNet

WebInterface (last edited 2015-04-05 01:29:12 by PierreGilbert)