kaypel wrote on Jan 20th, 2010, 5:07am:you’re growing with your challenge.
Can hardly argue with that, just ensure you don't bite more than you can chew (festival of common sense quotes).
Let's try with some simple code, as blindfish suggested:
Code:void setup()
{
String[] googlesuche = loadStrings("http://www.google.de/");
println(googlesuche[0]);
}
OK, it works. Note, since you point to openprocessing: such code won't work in an applet, unless you learn how to sign it...
Now, I will look why the request part isn't handled.
[EDIT] Found it. I vaguely suspected this, it have been confirmed by
Newbie - How do you request a web page from within Java thread: you have to make Google believe you are a real Web browser as it avoids being bugged by stupid bots.
Code:String QUERY = "http://www.google.de/search?q=Processing";
void setup()
{
String[] results = null;
try
{
URL url= new URL(QUERY);
URLConnection connection = url.openConnection();
// Google rejects pure API requests, so we change the header of the request
// to make it believe it is requested by a real browser... :)
connection.setRequestProperty("User-Agent",
"I am a real browser like Mozilla or MSIE" );
results = loadStrings(connection.getInputStream());
}
catch (Exception e) // MalformedURL, IO
{
e.printStackTrace();
}
if (results != null)
{
println(results[2]);
}
}