|
Author |
Topic: Re: Reading HTML files online (Read 458 times) |
|
TomC
|
Re: Reading HTML files online
« on: Oct 6th, 2004, 1:17pm » |
|
(edit: As fjen points out below, the original poster has removed the first question in this thread. So the rest might not make much sense, but some of it could be useful.) When it's online, an applet can only read files from the same domain as it came from. So your example of loading html from the same folder should work. (With loadStrings or loadBytes, right?). I think you need to use the full http path, since I think unadorned file names need to be in the jar file (in the data directory before you export the applet). If that doesn't fix it, can you show us the code?
|
« Last Edit: Oct 10th, 2004, 1:58pm by TomC » |
|
|
|
|
bsr
|
Re: Reading HTML files online
« Reply #1 on: Oct 6th, 2004, 1:45pm » |
|
correct me if i'm wrong but i think loadstrings/bytes compiles the data into the .jar so it can't be used for live data? for live data you'd have to pass information in via the <applet> tags?
|
http://hippocamp.net
|
|
|
TomC
|
Re: Reading HTML files online
« Reply #2 on: Oct 6th, 2004, 1:55pm » |
|
No, you can load things from the same domain using loadStrings/Bytes. I do it here: http://www.tom-carden.co.uk/p5/flickr_rainbow_links_fixed/applet/index.h tml It uses loadStrings with a full http path to get data from a PHP page in the same folder on the server. (The PHP page forwards info from flickr.com). The same can also be done with images. I stand by the Processing code, but not the PHP The data folder gets bundled into the jar file, and can also be accessed with loadStrings/loadBytes/loadImage. But remote file loading over http is possible from the same domain.
|
|
|
|
bsr
|
Re: Reading HTML files online
« Reply #3 on: Oct 6th, 2004, 1:57pm » |
|
wicked - everything just got more useful! shame i'm on a bloody .asp server nasty nasty vb.
|
http://hippocamp.net
|
|
|
fjen
|
Re: Reading HTML files online
« Reply #4 on: Oct 6th, 2004, 11:31pm » |
|
ufff .. so much code here ... i found some issues in the drawurl() method. fixed them and seems to work for me .. (1) when you try to grab the last element of an array then urlList[urlList.length] will give you an error. this is because arrays in java start by 0 so actually the last element is urlList[urlList.length-1] see: http://java.about.com/library/weekly/aa_array.htm (2) some of you float->int->float conversions are useless. like: float un = float(urlList.length); //numero de elementos na lista ... float r = ( 6.28 / float(un)*i); // no need to do float() again, "un" is a float as declared above ... /F here's the part i changed: Code: void drawurl(){ UrlChopper uc = new UrlChopper(); pagedata = loadStrings(strURL); urlList = uc.getUrls(pagedata); // lista de urls float un = float(urlList.length-1); //numero de elementos na lista int f; f=int(random(urlList.length-1)); //random link da lista strURL2 = urlList[f]; if ( strURL2.indexOf("http") == 0){ strURL2 = strURL2; // se o link comeÁar com http ent?o È valido } else{ //strURL2 = strURL; // se o link n?o comeÁar co http ent?o volta ao inicial strURL2 = "http://www.sapo.pt"; } strURL = strURL2; for(int i=0; i<un; i++){ float r = ( 6.28 / un*i); // quadrados distribuidos em circulo |
|
|
« Last Edit: Oct 6th, 2004, 11:53pm by fjen » |
|
|
|
|
fjen
|
Re: Reading HTML files online
« Reply #5 on: Oct 6th, 2004, 11:45pm » |
|
oh, and read error are not handled ( java.io.FileNotFoundException ). this happend when loadstrings can't find the file .. will give you an NullPointerException ... just put a catch in the getUrls() like this: Code:String[] getUrls( String[] ls ){ int ai; // indexnposicao de '<a href' String u; //url String l; // linha de data do html String[] urlList = new String[0]; //array para os url data if (ls == null) return (new String[]{"http://www.sapo.pt"}); ..... |
|
|
« Last Edit: Oct 6th, 2004, 11:52pm by fjen » |
|
|
|
|
fjen
|
Re: Reading HTML files online
« Reply #6 on: Oct 10th, 2004, 5:35am » |
|
hmm .. now this is funny. victor, why did you remove your posts? /F
|
|
|
|
xoff
|
Re: Reading HTML files online
« Reply #7 on: Oct 11th, 2004, 1:02am » |
|
grrr.. 2 diferent logins. :s forgot that i already had one acount . trying to clean up and made a mess..sorry. but hey here is the link for the thing. it is a demo version reading 10 html pages that are linked one to another on the site. For a full working version i'm implementing a textfield and cleanng the design. maybe tomorow demo version: http://xslab.com.sapo.pt/
|
||||||||||||||||||||||||| 25% lodead
|
|
|
|