Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

171
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!