在我的Android應用程序中,我想從用戶獲取搜索查詢,並使用該查詢搜索谷歌,獲取搜索結果並用搜索結果填充列表。自定義搜索API每天限制爲100次免費搜索。那麼搜索有沒有其他選擇?在android應用中獲取Google的搜索結果
2
A
回答
7
這是你可以使用的東西。
http://google.com/complete/search?output=toolbar&q=查詢
它返回的XML文件。解析該XML以獲得結果。 但谷歌可能會在未來改變查詢的格式。這是唯一關心的問題。否則它效果很好。
爲便於將來參考,請注意以下針對其他有用網站的查詢。一些返回JSON和其他XML格式。
http://suggestqueries.google.com/complete/search?hl=en&ds=yt&client=youtube&hjson=t&cp=1&q=查詢 & ALT = JSON
http://search.yahooapis.com/WebSearchService/V1/relatedSuggestion?appid=YahooDemo&query=查詢
http://en.wikipedia.org/w/api.php?action=opensearch&search=查詢 &限制= 10 &命名空間= 0 &格式= JSON
http://anywhere.ebay.com/services/suggest/?q=查詢 & S = 0
http://completion.amazon.com/search/complete?method=completion&q=查詢 &搜索別名爲APS & MKT = 1個
http://api.bing.net/osjson.aspx?Query=查詢 &市場= EN-US
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" />
另外補充許可互聯網
相關問題
- 1. 如何使用Java在Android中獲取Google搜索結果?
- 2. 使用JSoup獲取Google搜索結果
- 3. 使用Rails獲取Google搜索結果
- 4. 如何在android應用程序中獲取google地圖搜索結果?
- 5. 獲取Google討論搜索結果
- 6. 提取Google搜索結果
- 7. 在Google中搜索結果
- 8. 在PHP中搜索Google搜索結果
- 9. Google應用索引ios搜索結果
- 10. 如何從應用程序後端獲取Google搜索結果?
- 11. 在JavaScript中使用JSON從Google搜索獲取結果Ajax API
- 12. 如何在Google搜索結果頁中提取搜索結果的總量
- 13. 從Google搜索結果網址獲取搜索查詢
- 14. Google Maps API Places搜索獲取搜索結果數量
- 15. 從Bing搜索獲取搜索結果
- 16. 獲取搜索結果中的頁數
- 17. 使用PHP獲取Google搜索API的結果
- 18. 提取Google搜索結果重定向
- 19. 如何在Android應用中搜索Google?
- 20. 無法使用JSON獲取Google自定義搜索結果
- 21. 如何使用jquery獲取Google搜索API結果href值
- 22. Python。從Google搜索結果中僅獲取href鏈接內容
- 23. 從php獲取搜索結果在php
- 24. 獲取谷歌搜索結果在c#
- 25. 如何在Excel中使用VBA獲取首頁的Google搜索結果片段
- 26. google api搜索結果
- 27. 訪問Google搜索結果
- 28. Google搜索結果限制
- 29. Google地方搜索結果
- 30. 優化Google搜索結果