Commit eb54f471 by [zhangzhiwei]

修改评论http访问方式

parent cb6a0b84
......@@ -13,6 +13,8 @@ import org.apache.logging.log4j.Logger;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.zhiwei.crawler.core.HttpBoot;
import com.zhiwei.crawler.core.RequestUtils;
import com.zhiwei.tools.httpclient.HttpClientTemplateOK;
import com.zhiwei.tools.tools.ZhiWeiTools;
import com.zhiwei.toutiao.bean.TouTiaoComment;
......@@ -27,7 +29,7 @@ import com.zhiwei.toutiao.util.Tools;
public class TouTiaoCommentParse {
private static Logger logger = LogManager.getLogger(TouTiaoCommentParse.class);
private static HttpBoot httpBoot = new HttpBoot();
/**
*
......@@ -135,7 +137,7 @@ public class TouTiaoCommentParse {
String urlNew = "http://www.toutiao.com/api/comment/list/?group_id="+group_id+"&item_id=0&count=20&offset=0";
//设置头信息
Map<String,String> headerMap = Tools.getTouTiaoHeader();
String htmlBody = HttpClientTemplateOK.get(urlNew, proxy,headerMap);
String htmlBody = httpBoot.syncCall(RequestUtils.wrapGet(urlNew, headerMap),proxy).body().string();
if(htmlBody!=null)
{
......@@ -172,7 +174,7 @@ public class TouTiaoCommentParse {
try {
//设置头信息
Map<String,String> headerMap = Tools.getTouTiaoHeader();
String htmlBody = HttpClientTemplateOK.get(url, proxy,headerMap);
String htmlBody = httpBoot.syncCall(RequestUtils.wrapGet(url, headerMap),proxy).body().string();
if(htmlBody!=null && htmlBody.contains("commentInfo"))
{
try {
......@@ -199,12 +201,12 @@ public class TouTiaoCommentParse {
* @param @return 设定文件
* @return int 返回类型
*/
public static int findCommentCountByNewProxy(String url,Proxy proxy)
public static int findNewCommentCountByProxy(String url,Proxy proxy)
{
try {
//设置头信息
Map<String,String> headerMap = Tools.getTouTiaoHeader();
String htmlBody = HttpClientTemplateOK.get(url, proxy,headerMap);
String htmlBody = httpBoot.syncCall(RequestUtils.wrapGet(url, headerMap),proxy).body().string();
if(htmlBody!=null && htmlBody.contains("commentInfo"))
{
try {
......@@ -236,8 +238,7 @@ public class TouTiaoCommentParse {
String urlNew = "http://www.toutiao.com/api/comment/list/?group_id="+group_id+"&item_id=0&count=20&offset=0";
//设置头信息
Map<String,String> headerMap = Tools.getTouTiaoHeader();
String htmlBody = HttpClientTemplateOK.get(urlNew, proxy,headerMap);
String htmlBody = httpBoot.syncCall(RequestUtils.wrapGet(urlNew, headerMap),proxy).body().string();
if(htmlBody!=null)
{
try {
......@@ -300,7 +301,7 @@ public class TouTiaoCommentParse {
String groupId = null;
Map<String,String> headerMap = Tools.getTouTiaoHeader();
try {
String htmlBody = HttpClientTemplateOK.get(url, proxy,headerMap);
String htmlBody = httpBoot.syncCall(RequestUtils.wrapGet(url, headerMap),proxy).body().string();
if(htmlBody != null)
{
if(htmlBody.contains("groupId"))
......
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