Difference between revisions of "Read data from URL on internet"

m
 
(One intermediate revision by one other user not shown)
Line 8: Line 8:
 
==ReadFromUrl(url, ''method, formValues, formFields, formIndex'')==
 
==ReadFromUrl(url, ''method, formValues, formFields, formIndex'')==
  
[[ReadFromUrl]] reads text or images from a URL (Universal Resource Locator) location on the web. In most cases, this is called with a single parameter -- the URL. When reading from a web page, «url» should begin with <nowiki>'http://....'</nowiki>. When reading a text file from an FTP site, it should begin with <nowiki>'ftp://...'</nowiki>. The entire text from the requested location is returned as a text value. In most cases, you will need to write Analytica expressions to parse the data. When the URL is an http request that points to an image (*.jpg, *.png, *.gif, etc), a picture object is returned that can be assigned to the pict attribute of objects. With the exception of http requests to known image types, the source data must be textual, and if not, the resulting data will be garbled.
+
[[ReadFromUrl]] reads text or images from a URL (Universal Resource Locator) location on the web. In most cases, ypu can call it with a single parameter -- the URL. When reading from a web page, the «url» should begin with <nowiki>'http://....'</nowiki>. When reading a text file from an FTP site, it should begin with <nowiki>'ftp://...'</nowiki>. It returns the entire text as a text value. In most cases, you will need to write Analytica expressions to parse the data. When the URL is an http request that points to an image (*.jpg, *.png, *.gif, etc), it returns a picture object, which you can assign to the Pict attribute of objects, or into an array. With the exception of http requests to known image types, the source data must be textual, and if not, the resulting data will be garbled.
  
Some web pages and most FTP sites require user and password authentication to access. To authenticate, embed the user name and password in the URL as follows:
+
Some web pages and most FTP sites require user and password authentication to access. To authenticate, embed the user name and password in the URL, like this:
  
 
:<code>ReadFromUrl(<nowiki>'http://user:password@www.site.com/dir/page.htm'</nowiki>)</code>
 
:<code>ReadFromUrl(<nowiki>'http://user:password@www.site.com/dir/page.htm'</nowiki>)</code>
Line 26: Line 26:
  
  
<footer>Read and write text files / {{PAGENAME}} / Copy and Paste between applications</footer>
+
<footer>Excel spreadsheets read and write / {{PAGENAME}} / Import and Export data</footer>

Latest revision as of 22:31, 8 August 2017


The ReadFromUrl function, on the Database menu, reads text from URL sources, such as HTTP web pages or FTP sites.

This feature is available in Analytica Enterprise and Optimizer.

ReadFromUrl(url, method, formValues, formFields, formIndex)

ReadFromUrl reads text or images from a URL (Universal Resource Locator) location on the web. In most cases, ypu can call it with a single parameter -- the URL. When reading from a web page, the «url» should begin with 'http://....'. When reading a text file from an FTP site, it should begin with 'ftp://...'. It returns the entire text as a text value. In most cases, you will need to write Analytica expressions to parse the data. When the URL is an http request that points to an image (*.jpg, *.png, *.gif, etc), it returns a picture object, which you can assign to the Pict attribute of objects, or into an array. With the exception of http requests to known image types, the source data must be textual, and if not, the resulting data will be garbled.

Some web pages and most FTP sites require user and password authentication to access. To authenticate, embed the user name and password in the URL, like this:

ReadFromUrl('http://user:password@www.site.com/dir/page.htm')
ReadFromUrl('ftp://user:password@site.com/directory/file.txt')

The optional second through fourth parameters are used to submit data to web forms. There are two methods used to submit data to HTTP web forms: method: 'POST'or method: 'GET'. The field names and the values submitted for those fields are specified in «formValues» and «formFields», which must share a common index, and if that common index is anything other than «formFields», it should be specified in the «formIndex» parameter.

See Also


Comments


You are not allowed to post comments.