We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › URL: open() works, but not loadStrings()
Page Index Toggle Pages: 1
URL: open() works, but not loadStrings() (Read 639 times)
URL: open() works, but not loadStrings()
Dec 6th, 2009, 1:34pm
 
I want to get the HTML code of a website.
The getStrings() function works not for all ?
But nevertheless I can open the page...?
I have no clue.


String url = "http://news.google.fr/nwshp?hl=fr&tab=wn";
String [] htmlarray;
open("http://news.google.fr/nwshp?hl=fr&tab=wn");
htmlarray  = loadStrings(url);

--->
gives the following error: The file "http://news.google.fr/nwshp?hl=fr&tab=wn" is missing or inaccessible, make sure the URL is valid or that the file has been added to your sketch and is readable.
Re: URL: open() works, but not loadStrings()
Reply #1 - Dec 6th, 2009, 2:17pm
 
this is not how you supposed to use it. open is used for executing other applications . http://processing.org/reference/open_.html

for opening a website you use link() but not in this case.
You need to parse the website to get the information you are looking for.
Right now you are loading the whole website, or at least try.
What information do you expect to load into your htmlarray ?

you can use proXML to parse the RSS feed.
http://creativecomputing.cc/p5libs/proxml/
http://news.google.fr/news?pz=1&cf=all&ned=fr&hl=fr&output=rss

some other people might be able to give you some more information on how exactly to do that.

Page Index Toggle Pages: 1