1
要設置搜索結果只在一個範圍內的日期的,有2種方式的方法:如何解析特定日期範圍內的Google搜索結果?
1)添加谷歌搜索關鍵字與谷歌搜索算
&
2)建模的網址(添加後綴)。
在我的Java應用程序,我想通過JSOUP日期的特定範圍刮谷歌新聞搜索結果(鏈接&冠軍),就像2016
不過,我試過的方法,所有這3種方式(包含非2016年的結果)。即使通過我在谷歌搜索框(谷歌網站)中累積了這3種方法或添加了網址後綴,他們也無法發現2016年的結果。
如何解決這個問題?
通過添加谷歌搜索關鍵字:
字符串搜索= 「計算器日期範圍:2016-01-01..2016-12-31」
字符串搜索=「計算器日期範圍:2457389-2457735 「
添加URL:
+」 & TBS = CDR%3A1% 2Ccd_min%3A1%2F1%2F2016%2Ccd_max%3A12%2F31%2F2016"
代碼:
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");
....}