4
$\begingroup$

There is no 'MinItems' suboption, so what is the limit per request? How can I page through results, say like if I wanted the first 2k images from a search?

results = 
 ServiceExecute["GoogleCustomSearch", 
  "Search", {"Query" -> "Albrecht Altdorfer", MaxItems -> 2000, 
   "SearchType" -> "Image"}]

enter image description here

Update:

I tried using C.E.'s suggestion:

Do[
 idx = 0;
 b = Internal`Bag[];
 {t, res} = AbsoluteTiming[While[True,
    Check[
     Internal`StuffBag[b, 
      Normal[ServiceExecute["GoogleCustomSearch", 
         "Search", {"Query" -> "Dali", MaxItems -> step, 
          "StartIndex" -> idx, "SearchType" -> "Image"}][All, 
        "ImageLink"]]], Break[]];
    idx = idx + step;
    ]];
 Print[Row@{"step = ", step, ", count = ", 
    Length@Flatten@Internal`BagPart[b, All], ", time = ", 
    t}], {step, {1, 2, 10, 50}}]

But with the free tier Google blocks you after 100 requests:

enter image description here

and after 1k results you are blocked for the day:

enter image description here

So the question remains how to pull images with StartIndex > 100 in a single day.

$\endgroup$
  • $\begingroup$ There is a StartIndex parameter right below MaxItems in the documentation. Did you try it? $\endgroup$ – C. E. Aug 16 '16 at 19:48
  • $\begingroup$ Have you tried it? Did it work? $\endgroup$ – C. E. Aug 19 '16 at 20:28
  • $\begingroup$ @C.E. See my updates. $\endgroup$ – M.R. Aug 20 '16 at 23:34
  • $\begingroup$ Maybe I'm just dense but I'm having a hard time deciphering this. You're saying "so the question remains..." as if the problem is partially solved, but you have many error messages, where do they come from? And why is count always 101, shouldn't it be increasing by step? It is also unclear if the limit is 100 or 1000. $\endgroup$ – C. E. Aug 21 '16 at 21:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.