OpenFile() from "http://" address

Hi,

Does anyone know if there is a way to use openfile() for a web address starting with "http://". I get undefined all the time. Any html is just an ascii file, so I guess the address is the problem here.
I don't want to view it, I just want to read it and search for some strings.
Any ideas?

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
br0t's picture

that looks like a real nice

that looks like a real nice breakdown how to access data from the web, thanks!

Never get low & slow & out of ideas

sTeapot's picture

.. nevermind, I figured it

.. nevermind, I figured it out :)
-> ActiveXControl

Anubis's picture

use .Net WebClient

OpenFile is for local files.
Here is 3 variants i have in mind -

-- ref WebClient object:
netWC = (dotNetObject "System.Net.WebClient")
 
--//variant 1 - download the file:
urlFile = "http://project3d.narod.ru/rss/rss.xml"
destFile = "C:\\temp\\" + (filenameFromPath urlFile)
netWC.downloadFile urlFile destFile
 
--//variant 2 - download as string:
stream = (netWC.DownloadString urlFile) as stringStream
 
--//variant 3 - read as stream from the server:
stream = netWC.OpenRead urlFile
source = if stream.CanRead then (
	sr = dotNetObject "System.IO.StreamReader" stream
	retStr = sr.ReadToEnd(); sr.Dispose()
	retStr
) else ""
stream.Close()
free stream

Cheers!

my recent MAXScripts RSS (archive here)

sTeapot's picture

Sweet! Thanks for the

Sweet!
Thanks for the alternatives!
Didn't see your post when I replied to myself

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.