Commit 061bc022 by zhiwei

提交新的js加密参数

parent 048700cc
......@@ -117,8 +117,8 @@ public class TouTiaoArticleParse {
/**
* 获取今日头条历史文章接口新
*
* @param user_id
* @param max_behot_time
* @param userId
* @param maxBehotTime
* @param endData
* @param proxy
* @return
......@@ -353,12 +353,15 @@ public class TouTiaoArticleParse {
*/
public static Map<String, Object> getMicroTouTiaoCrawler(String userId, Date endDate, Proxy proxy,
String maxBehotTime) throws IOException {
String url = "https://www.toutiao.com/api/pc/feed/?category=pc_profile_ugc&utm_source=toutiao&visit_user_id=" + userId;
if (maxBehotTime != null) {
url = url + "&max_behot_time=" + maxBehotTime;
Signature signature = new Signature(userId, maxBehotTime);
String signatureStr = signature.getSignature();
if (StringUtils.isBlank(maxBehotTime)) {
maxBehotTime = "0";
}
String url = "https://www.toutiao.com/api/pc/feed/?category=pc_profile_ugc&utm_source=toutiao&visit_user_id=" + userId + "&max_behot_time=" + maxBehotTime+ "&_signature=" + signatureStr;
System.out.println(url);
Map<String, String> headerMap = Tools.getTouTiaoHeader();
headerMap.put("User-Agent", "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36");
headerMap.put("Referer", "https://www.toutiao.com/c/user/" + userId + "/");
try {
String htmlBody = downloadHtml(url, proxy, headerMap);
......@@ -379,10 +382,13 @@ public class TouTiaoArticleParse {
public static Map<String, Object> getMicroTouTiaoCrawler(String userId, Date endDate, ProxyHolder proxy,
Long maxBehotTime) throws IOException {
String url = "https://www.toutiao.com/api/pc/feed/?category=pc_profile_ugc&utm_source=toutiao&visit_user_id=" + userId;
if (maxBehotTime != null) {
url = url + "&max_behot_time=" + maxBehotTime;
Signature signature = new Signature(String.valueOf(userId), String.valueOf(maxBehotTime));
String signatureStr = signature.getSignature();
if (Objects.isNull(maxBehotTime)) {
maxBehotTime = 0L;
}
String url = "https://www.toutiao.com/api/pc/feed/?category=pc_profile_ugc&utm_source=toutiao&visit_user_id=" + userId + "&max_behot_time=" + maxBehotTime+ "&_signature=" + signatureStr;
System.out.println(url);
logger.info("微头条采集链接:::{}", url);
Map<String, String> headerMap = Tools.getTouTiaoHeader();
headerMap.put("Referer", "https://www.toutiao.com/c/user/" + userId + "/");
......@@ -407,9 +413,8 @@ public class TouTiaoArticleParse {
*
* @Description 微头条客户端解析
* @param userId
* @param endDate
* @param proxy
* @param max_behot_time
* @param maxBehotTime
* @return
*/
public static List<Map<String,Object>> getClientMicroToutiaoCrawler(String userId, ProxyHolder proxy,
......@@ -487,6 +492,7 @@ public class TouTiaoArticleParse {
Long maxBehotTime = null;
List<TouTiaoArticle> dataList = new ArrayList<>();
try {
System.out.println("htmlBody====="+htmlBody);
JSONObject json = JSONObject.parseObject(htmlBody);
boolean more = false;
if(json.containsKey("has_more")) {
......@@ -726,7 +732,7 @@ public class TouTiaoArticleParse {
if(proxy != null) {
response = httpBoot.syncCall(RequestUtils.wrapGet(url,headMap),proxy);
}else {
response = httpBoot.syncCall(RequestUtils.wrapGet(url,headMap), ProxyHolder.NAT_HEAVY_PROXY);
response = httpBoot.syncCall(RequestUtils.wrapGet(url,headMap));
}
return response.body().string();
} catch (Exception e) {
......
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