Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/search/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何解析特定日期范围内的谷歌搜索结果?_Java_Search_Jsoup_Google Search_Google Custom Search - Fatal编程技术网

Java 如何解析特定日期范围内的谷歌搜索结果?

Java 如何解析特定日期范围内的谷歌搜索结果?,java,search,jsoup,google-search,google-custom-search,Java,Search,Jsoup,Google Search,Google Custom Search,要仅在日期范围内设置搜索结果,有两种方法: 1) 使用谷歌搜索运营商添加谷歌搜索关键字 & 2) 建模url(添加后缀) 在我的Java应用程序中,我想在JSOUP指定的日期范围内(如2016年)获取google新闻搜索结果(链接和标题) 然而,我尝试了这3种方法,没有一种是成功的(包含非2016年的结果)。即使我在谷歌搜索框(谷歌网站)中厌倦了这3种方法,或者添加了url后缀,他们也无法发现2016年的结果 如何解决这个问题 通过添加google搜索关键字: String search=“st

要仅在日期范围内设置搜索结果,有两种方法:

1) 使用谷歌搜索运营商添加谷歌搜索关键字

&

2) 建模url(添加后缀)

在我的Java应用程序中,我想在JSOUP指定的日期范围内(如2016年)获取google新闻搜索结果(链接和标题)

然而,我尝试了这3种方法,没有一种是成功的(包含非2016年的结果)。即使我在谷歌搜索框(谷歌网站)中厌倦了这3种方法,或者添加了url后缀,他们也无法发现2016年的结果

如何解决这个问题

通过添加google搜索关键字:

String search=“stackoverflow日期范围:2016-01-01..2016-12-31”

String search=“stackoverflow日期范围:2457389-2457735”

添加url:

+“&tbs=cdr%3A1%2Ccd_最小值%3A1%2F1%2F2016%2Ccd_最大值%3A12%2F31%2F2016”

代码:

stringgoogle=”http://www.google.com/search?q=";
String search=“stackoverflow日期范围:2016-01-01..2016-12-31”//使用谷歌搜索操作符(日期范围)
字符串charset=“UTF-8”;
String news=“&tbm=nws”;
String=google+URLEncoder.encode(搜索,字符集)+新闻;
String userAgent=“ExampleBot 1.0(+http://example.com/bot)"; 
System.setProperty(“http.proxyHost”、“192.168.5.1”);
set属性(“http.proxyPort”、“1080”);

对于(int j=0;j我也遇到了同样的问题,结果发现这是JSoup的1.10.2版本中的一个bug。转到并抓取1.10.3,它应该会修复它。所有这些都归功于谁回答了我的问题。

我遇到了同样的问题,结果发现这是JSoup的1.10.2版本中的一个bug。转到并抓取1.10.3,它应该会修复它。所有这些都是我的功劳感谢回答我问题的人

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

        String search = "stackoverflow daterange:2016-01-01..2016-12-31 "; //using the google search operators (daterange)

        String charset = "UTF-8";

        String news="&tbm=nws";

        String string = google + URLEncoder.encode(search , charset) + news;

        String userAgent = "ExampleBot 1.0 (+http://example.com/bot)"; 

        System.setProperty("http.proxyHost", "192.168.5.1");
        System.setProperty("http.proxyPort", "1080");
        for(int j=0;j<3;j++){
     Document document = Jsoup.connect(string+"&start="+(j+0)*10).userAgent(userAgent). ignoreHttpErrors(true).followRedirects(true).timeout(100000).ignoreContentType(true).get();
    Elements links = document.select( ".r>a");
....}