Commit f061889a by zhiwei

处理账号匹配规则

parent eedbd670
......@@ -44,13 +44,13 @@ public class TouTiaoAccountParse {
try {
String htmlBody = null;
htmlBody = HttpClientTemplateOK.get(url, proxy, headerMap);
if(htmlBody != null && htmlBody.contains("media_id")){
if(htmlBody != null ){
tta = parseHtmlByAccount(htmlBody, name, proxy);
if(tta == null){
url = "https://www.toutiao.com/search_content/?offset=0&format=json&keyword="+URLCodeUtil.getURLEncode(name, "utf-8")+"&autoload=true&count=20&cur_tab=4&from=media";
headerMap.put("Referer","https://www.toutiao.com/search/?keyword="+URLCodeUtil.getURLEncode(name, "utf-8"));
htmlBody = HttpClientTemplateOK.get(url, proxy, headerMap);
if(htmlBody != null && htmlBody.contains("media_id")){
if(htmlBody != null){
tta = parseHtmlByAccount(htmlBody, name, proxy);
}
}
......@@ -58,7 +58,7 @@ public class TouTiaoAccountParse {
url = "https://www.toutiao.com/search_content/?offset=0&format=json&keyword="+URLCodeUtil.getURLEncode(name, "utf-8")+"&autoload=true&count=20&cur_tab=4&from=media";
headerMap.put("Referer","https://www.toutiao.com/search/?keyword="+URLCodeUtil.getURLEncode(name, "utf-8"));
htmlBody = HttpClientTemplateOK.get(url, proxy, headerMap);
if(htmlBody != null && htmlBody.contains("media_id")){
if(htmlBody != null){
tta = parseHtmlByAccount(htmlBody, name, proxy);
}
}
......@@ -79,7 +79,7 @@ public class TouTiaoAccountParse {
try {
String htmlBody = null;
htmlBody = HttpClientTemplateOK.get(url, proxy, headerMap);
if(htmlBody != null && htmlBody.contains("mediaId")){
if(htmlBody != null){
tta = parseAccountByUserId(htmlBody, user_id);
}
......@@ -113,7 +113,7 @@ public class TouTiaoAccountParse {
try {
String htmlBody = null;
htmlBody = HttpClientTemplateOK.get(url, proxy, headerMap);
if(htmlBody != null && htmlBody.contains("media_id")){
if(htmlBody != null){
JSONObject json = JSONObject.parseObject(htmlBody);
list.addAll(parseHtmlByWord(json, proxy));
if(json.getIntValue("has_more")==0){
......@@ -192,9 +192,7 @@ public class TouTiaoAccountParse {
JSONArray jsonArray = json.getJSONArray("data");
for (int i = 0; i < jsonArray.size(); i++) {
try {
JSONObject data = jsonArray.getJSONObject(i);
if(data.containsKey("media_id")){
long user_id = data.getLong("id");
String name = data.getString("name");
long media_id = data.getLong("media_id");
......@@ -218,7 +216,6 @@ public class TouTiaoAccountParse {
}
return tta;
}
}
} catch (Exception e) {
logger.error("数据解析出现问题,{}", e);
continue;
......@@ -299,7 +296,6 @@ public class TouTiaoAccountParse {
for (int i = 0; i < jsonArray.size(); i++) {
try {
JSONObject data = jsonArray.getJSONObject(i);
if(data.containsKey("media_id")){
user_id = data.getLong("id");
name = data.getString("name");
media_id = data.getLong("media_id");
......@@ -321,7 +317,6 @@ public class TouTiaoAccountParse {
tta.setUser_type(ttaUpdate.getUser_type());
}
ttaList.add(tta);
}
} catch (Exception e) {
logger.error("数据解析出现问题,{}", e);
continue;
......
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