How to do a google search?

by Mattaku Betsujin » Fri, 06 Mar 2009 16:06:17 GMT


Sponsored Links
 I want to do a google search, so I open an HttpURLConnection() to
www.google.com. However, I am getting an error:

url =  http://www.google.com/search?& ;q=123

java.io.FileNotFoundException:  http://www.google.com/search?& ;q=123
   at
org.apache.harmony.luni.internal.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1040)
   at com.nubinews.reader.URLFetcher.readHttp(URLFetcher.java:535)
   at
com.nubinews.reader.URLFetcher$ConnectionThread.getText2Internal(URLFetcher.java:417)
   at
com.nubinews.reader.URLFetcher$ConnectionThread.getText2InThread(URLFetcher.java:365)
   at
com.nubinews.reader.URLFetcher$ConnectionThread.processCommands(URLFetcher.java:341)
   at
com.nubinews.reader.URLFetcher$ConnectionThread.run(URLFetcher.java:323)

and the response headers are:

HEADER: null = HTTP/1.1 403 Forbidden
HEADER: content-type = text/html; charset=UTF-8
HEADER: date = Fri, 06 Mar 2009 08:02:53 GMT
HEADER: server = gws
HEADER: cache-control = private, x-gzip-ok=""
HEADER: transfer-encoding = chunked

What should I do?

--~--~---------~--~----~------------~-------~--~----~



How to do a google search?

by Mattaku Betsujin » Fri, 06 Mar 2009 16:31:34 GMT


 I found a work-around. Instead of using HttpURLConnection, I open a socket
connection directly to www.google.com:80 and was able to get the search
results (in HTML data). It seems like Android's HttpURLConnection adds
request header to make my life miserable.

However, when I tried to print the request headers

        Map map = http.getRequestProperties();
        System.out.println(map);

It shows an empty collection.

What's happening? Does Google really doesn't want me to search? Please, I
beg you, let me search ........

On Fri, Mar 6, 2009 at 12:06 AM, Mattaku Betsujin <




--~--~---------~--~----~------------~-------~--~----~


Sponsored Links


How to do a google search?

by Mariano Kamp » Fri, 06 Mar 2009 19:09:42 GMT


 Just out of curiosity, have you tried the url without the "&"?. Afaik the
first parameter is passed in with a "?" and just the following parameters
are prefixed with the "?". But you did both for the first parameter.

On Fri, Mar 6, 2009 at 9:06 AM, Mattaku Betsujin <mattaku.betsu...@gmail.com




--~--~---------~--~----~------------~-------~--~----~



How to do a google search?

by Mariano Kamp » Fri, 06 Mar 2009 19:14:47 GMT


 > It seems like Android's HttpURLConnection adds request header [to make my
life miserable.]
How do you know?

The HTTPUrlConnection works fine for me. The documentation is a bit lacking,
but since I found the following code I am happy:

 http://www.google.com/codesearch/p?hl=en #uX1GffpyOZk/core/java/android/net/http/AndroidHttpClient.java&q=AndroidHttpClient.java

On Fri, Mar 6, 2009 at 9:31 AM, Mattaku Betsujin <mattaku.betsu...@gmail.com





--~--~---------~--~----~------------~-------~--~----~



How to do a google search?

by Mark Murphy » Fri, 06 Mar 2009 19:59:03 GMT


 


You do realize that what you are trying to do violates Google's Terms of
Service, right?

 http://www.google.com/accounts/TOS 

If you want to use Google's search, use their official APIs for search:

 http://code.google.com/apis/ajaxsearch/ 

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com 
_The Busy Coder's Guide to Android Development_ Version 2.0 Available!

--~--~---------~--~----~------------~-------~--~----~



Other Threads

1. Question about AlphaAnimation

I'm having trouble getting AlphaAnimation to work.  Can anyone explain
why the following patch to
com.example.android.apis.graphics.AnimateDrawables.java in the
provided samples does not produce an image that fades away?

--- AnimateDrawables.java.orig  2010-04-05 12:56:45.000000000 -0500
+++ AnimateDrawables.java       2010-04-05 12:57:39.000000000 -0500
@@ -46,7 +46,8 @@
             Drawable dr =
context.getResources().getDrawable(R.drawable.beach);
             dr.setBounds(0, 0, dr.getIntrinsicWidth(),
dr.getIntrinsicHeight());

-            Animation an = new TranslateAnimation(0, 100, 0, 200);
+            Animation an = new AlphaAnimation(1.0f, 0.0f);
             an.setDuration(2000);
             an.setRepeatCount(-1);
             an.initialize(10, 10, 10, 10);

I know that the Drawable properly responds to setAlpha().  I also
tried ensuring that the Transformation in
com.example.android.apis.graphics.AnimateDrawable.java was
setTransformationType(Transformation.TYPE_BOTH), even though I suspect
that is the default setting.

Is there some requirement of the View to allow for animated alpha
transparency that I'm missing?

Thanks for any help or explanation.

Iain

-- 

2. Question about stopping AlarmManager.

Hi,
I have a AppWidget, after I delete it from HomeScreen it seems not stopping
the AlarmManager attached with it. I have supported it with the AlarmManger,
that call the ProviderImplementation class every 1 minute and in onReceive I
put the code to call onUpdate. and in onDelete I explicitly stop the alarm,
but it seems it is running continously and not stopping. any cure of it ?

I have stopped it with cancel(pendingintent) function.

thank you,
Abdul Ma{*filter*}.

-- 

3. IPv6 Problem solved

4. SDK2.1, WVGA800 return wrong getWidth(), getHeight()

5. SDK won't install

6. commands to sent to device to run JUnit tests

7. Animal translate..