Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

170
Vistas
How to scrape every results in every pages with google search?

I m going to scrape every results in every pages with google search . I restricted the search time range to be :1/1/2016 to 31/12/2016

 String string = google + URLEncoder.encode(search , charset) + news+"&tbs=cdr%3A1%2Ccd_min%3A1%2F1%2F2016%2Ccd_max%3A12%2F31%2F2016";

I find that this is not working out .

I m using JSoup.

Now , I successfully scrape every results in a specific number of pages .numberOfResultpages

But I want to scrape every results in every pages google could find (NOT in a specific number of pages)

Here is my work.

 public static void main(String[] args) throws UnsupportedEncodingException, IOException {

          String[] line = new String[100];
      final int[] score = {    0};


        String google = "http://www.google.com/search?q=";

        String search = "stackoverflow";

        String charset = "UTF-8";

        String news="&tbm=nws";



String string = google + URLEncoder.encode(search , charset) + news+"&tbs=cdr%3A1%2Ccd_min%3A1%2F1%2F2016%2Ccd_max%3A12%2F31%2F2016";

     int numberOfResultpages = 10; // >==grabs specific number of pages only

    int idx = 0;
for (int i = 0; i < numberOfResultpages; i++) {

       Document document = Jsoup.connect(string).userAgent(userAgent) .data("start",""+i).get();
    Elements links = document.select( ".r>a");

        for (Element link : links) {

            String title = link.text();
            String url = link.absUrl("href"); // Google returns URLs in format "http://www.google.com/url?q=<url>&sa=U&ei=<someKey>".
            url = URLDecoder.decode(url.substring(url.indexOf('=') + 1, url.indexOf('&')), "UTF-8");

            if (!url.startsWith("http")) {
                continue; // Ads/news/etc.
            }
            System.out.println("Title: " + title);
            System.out.println("URL: " + url);

            line[idx++]=title;
       // }

}
     }
over 4 years ago · Santiago Trujillo
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda