3

私のAndroidアプリケーションでは、ユーザーから検索クエリを取得し、そのクエリでGoogleを検索し、検索結果を取得して、検索結果をリストに入力したいと考えています. カスタム検索 API は、1 日あたり 100 件の無料検索に制限されています。では、検索に代わるものはありますか?

4

2 に答える 2

8

これはあなたが使用できるものです。

http://google.com/complete/search?output=toolbar&q= query

XMLファイルを返します。そのxmlを解析して、結果を取得します。しかし、グーグルは将来クエリのフォーマットを変更するかもしれません。ここでの唯一の懸念事項です。そうでなければ、それはうまくいきます。

今後の参考のために、他の有用なWebサイトに関する次のクエリに注意してください。JSONで返されるものと、XML形式で返されるものがあります。

http://suggestqueries.google.com/complete/search?hl=en&ds=yt&client=youtube&hjson=t&cp=1&q= query&alt = json

http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=YahooDemo&query= query

http://en.wikipedia.org/w/api.php?action=opensearch&search= query&limit = 10&namespace = 0&format = json

http://anywhere.ebay.com/services/suggest/?q= query&s = 0

http://completion.amazon.com/search/complete?method=completion&q= query&search-alias = aps&mkt = 1

http://api.bing.net/osjson.aspx?Query= query&Market = en-us

于 2012-09-02T19:12:16.167 に答える
1

このコードを使用して試すことができます

MainActivity.java

private EditText editTextInput;

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_g__search);

editTextInput = (EditText) findViewById(R.id.editTextInput);
}

public void onSearchClick(View v)
{
try {
Intent intent = new Intent(Intent.ACTION_WEB_SEARCH);
String term = editTextInput.getText().toString();
intent.putExtra(SearchManager.SUGGEST_URI_PATH_QUERY, term);
startActivity(intent);
} catch (Exception e) {
// TODO: handle exception
}

}

Activity_layout.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
 >


<EditText
    android:id="@+id/editTextInput"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:ems="10" >

    <requestFocus />
</EditText>

<Button
    android:id="@+id/button1"
    style="?android:attr/buttonStyleSmall"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignRight="@+id/editTextInput"
    android:layout_below="@+id/editTextInput"
    android:layout_marginRight="43dp"
    android:layout_marginTop="60dp"
    android:onClick="onSearchClick"
    android:text="CLICK" />

インターネットの許可も追加する

于 2013-03-20T10:21:11.760 に答える