2016-02-25 25 views
6

で100を超える結果を得ることができませんGoogleカスタム検索API https://developers.google.com/custom-search/v1/overviewを使用する必要があります。そのページから、それは言った:googleカスタム検索api

For CSE users, the API provides 100 search queries per day for free. If you need more, you may sign up for billing in the Developers Console. Additional requests cost $5 per 1000 queries, up to 10k queries per day.

私はすでにデベロッパーコンソールの中で請求にサインアップしています。しかし、私はまだ100以上の結果を取得することができませんでした。私は何をもっとしなければなりませんか? https://www.googleapis.com/customsearch/v1?cx=CSE_INSTANCE&key=API_KEY&q=QUERY&start=100

{ error: { errors: [ { domain: "global", reason: "invalid", message: "Invalid Value" } ], code: 400, message: "Invalid Value" } }

答えて

2

クエリ:定義
https://support.google.com/customsearch/answer/1361951

Any actual user query from a Google Site Search engine, including but not limited to search engines installed on your website using XML, iFrame, or the Custom Search Element.

あなたはおそらく11 100の以上の結果を得るためにに照会を送信する必要がありますを意味します。

GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=1 
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=11 
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=21 
GET ... 
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=81 
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=91 
GET https://www.googleapis.com/customsearch/v1?&q=QUERY&...&start=101 

チェックすべての応答をしてerrorcode400されている場合は、停止することができます - 次の(&start=前の+ 10)リクエストを送信する必要はおそらくありません。

これで、応答をマージして建物の結果ページを開始できます。

Google Custom Search and Google Site Search return up to 10 results per query. If you want to display more than 10 results to the user, you can issue multiple requests (using the start=0, start=11 ... parameters) and display the results on a single page. In this case, Google will consider each request as a separate query, and if you are using Google Site Search, each query will count towards your limit.

私は上記で説明したより良い方法があります。 (しかし、私は確信していない約batching API calls

あなたの質問への可能な答え:私はいくつかのテストを行ったが、私はstart 100以上の幸運を持っていないあなたと同じ - <Response [400]>)。私は、請求可能なプロジェクトから「ブラウザキー」を使用しています。 CSE APIの結果はThat could mean we can't get 101st, 102nd, 103rd, etc.です。

+0

私の要求では、totalResultsが97400であることがわかりました。しかし、100レコード以上の結果を得ることはできませんでした。 – Chamnap

+0

どうすればいいですか? – Chamnap

+0

あなたについてはわかりませんが、私は自分の答えを完全に書き直すべきだと思います。それは間違っている、申し訳ありません。そして、私には良いニュースはありません、再び申し訳ありません。 – galeksic

関連する問題