Commit 26dc222c by [zhangzhiwei]

微头条数据处理

parent 9e236728
...@@ -188,7 +188,7 @@ public class TouTiaoArticleParse { ...@@ -188,7 +188,7 @@ public class TouTiaoArticleParse {
logger.info("数据为null"); logger.info("数据为null");
} }
} catch (Exception e) { } catch (Exception e) {
logger.info("获取数据出错::{},数据为null", e.fillInStackTrace()); logger.info("获取数据出错::{},数据为null", e);
return null; return null;
} }
return null; return null;
...@@ -246,7 +246,6 @@ public class TouTiaoArticleParse { ...@@ -246,7 +246,6 @@ public class TouTiaoArticleParse {
continue; continue;
} }
} }
System.out.println(source+"========="+dataList.size());
/**验证是否有下一页数据**/ /**验证是否有下一页数据**/
if(more){ if(more){
if(max_behot_time!=null && max_behot_time!=0){ if(max_behot_time!=null && max_behot_time!=0){
...@@ -261,7 +260,7 @@ public class TouTiaoArticleParse { ...@@ -261,7 +260,7 @@ public class TouTiaoArticleParse {
e.printStackTrace(); e.printStackTrace();
} }
map.put("max_behot_time", max_behot_time+""); map.put("max_behot_time", max_behot_time);
map.put("data", dataList); map.put("data", dataList);
return map; return map;
......
...@@ -31,7 +31,7 @@ public class TouTiaoExample { ...@@ -31,7 +31,7 @@ public class TouTiaoExample {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
long a = System.currentTimeMillis(); long a = System.currentTimeMillis();
List<String> urlList = new ArrayList<String>(); List<String> urlList = new ArrayList<String>();
urlList.add("5757091251"); urlList.add("23782107381");
System.out.println(urlList.size()); System.out.println(urlList.size());
...@@ -39,16 +39,17 @@ public class TouTiaoExample { ...@@ -39,16 +39,17 @@ public class TouTiaoExample {
for (String url : urlList) { for (String url : urlList) {
String mid = url; String mid = url;
String max_behot_time = "0"; Long max_behot_time = 0L;
while (true) { boolean f = true;
while (f) {
Map<String, Object> dataMap = null; Map<String, Object> dataMap = null;
dataMap = TouTiaoArticleParse.getMicroTouTiaoCrawler(mid, endTime, null, max_behot_time); dataMap = TouTiaoArticleParse.getMicroTouTiaoCrawler(mid, endTime, null, max_behot_time+"");
if (dataMap != null) { if (dataMap != null) {
List<TouTiaoArticle> ttlist = (List<TouTiaoArticle>) dataMap.get("data"); List<TouTiaoArticle> ttlist = (List<TouTiaoArticle>) dataMap.get("data");
max_behot_time = (String) dataMap.get("max_behot_time"); max_behot_time = (Long)dataMap.get("max_behot_time");
System.out.println(max_behot_time + "=======" + ttlist.size()); System.out.println(max_behot_time + "=======" + ttlist.size());
if (max_behot_time == null || ttlist.isEmpty()) { if (null == max_behot_time || ttlist.isEmpty()) {
break; f = false;
} else { } else {
if (ttlist.size() > 0) { if (ttlist.size() > 0) {
for (TouTiaoArticle tt : ttlist) { for (TouTiaoArticle tt : ttlist) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment