fix:博客资源

上级 9937f94b
package com.kwan.springbootkwan.controller; package com.kwan.springbootkwan.controller;
import com.kwan.springbootkwan.entity.Result; import com.kwan.springbootkwan.entity.Result;
import com.kwan.springbootkwan.entity.resp.BusinessInfo;
import com.kwan.springbootkwan.service.CsdnService; import com.kwan.springbootkwan.service.CsdnService;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
...@@ -20,14 +22,22 @@ public class CsdnController { ...@@ -20,14 +22,22 @@ public class CsdnController {
@ApiOperation(value = "获取数据", notes = "获取数据") @ApiOperation(value = "获取数据", notes = "获取数据")
@GetMapping("/list") @GetMapping("/list")
public Result get() { public Result get() {
final String articleId = service.list(); final BusinessInfo.ArticleData.Article article = service.list();
final String type = article.getType();
if (!StringUtils.equals("blog", type)) {
return Result.ok("非博客不能评论");
}
final String urlInfo = article.getUrl();
String articleId = urlInfo.substring(urlInfo.lastIndexOf("/") + 1);
System.out.println(articleId); System.out.println(articleId);
final Boolean articleInfo = service.getArticleInfo(articleId); final Boolean articleInfo = service.getArticleInfo(articleId);
if (!articleInfo) { if (!articleInfo) {
//进行点赞和评论 //进行点赞和评论
service.like(articleId); service.like(articleId);
service.comment(articleId); service.comment(articleId);
return Result.ok("三连完成");
} else {
return Result.ok("文章已经评论过,不能再次评论");
} }
return Result.ok("流程处理完成");
} }
} }
package com.kwan.springbootkwan.entity.resp;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.util.List;
@Data
public class ArticleInfo {
private String traceId;
private Integer code;
private ArticleInfoData data;
private String message;
@Data
public static class ArticleInfoData {
private Integer pageCount;
private Integer floorCount;
private Integer count;
@JsonProperty("list")
private List<ArticleInfoDataList> list;
private Integer foldCount;
@Data
public static class ArticleInfoDataList {
private Object pointCommentId;
private Info info;
@Data
public static class Info {
private Boolean flag;
private String dateFormat;
private String vipUrl;
private Object redEnvelopeInfo;
private Integer digg;
private String parentUserName;
private String content;
private Integer years;
private String parentNickName;
private Boolean loginUserDigg;
private String postTime;
private Boolean companyBlog;
private Boolean vip;
private String levelIcon;
private String orderNo;
private String companyBlogIcon;
private String nickName;
private Integer articleId;
private String flagIcon;
private String avatar;
private String userName;
private Integer parentId;
private String vipIcon;
private Boolean isBlack;
private Boolean isTop;
private Integer commentId;
private CommentFromTypeResult commentFromTypeResult;
private String region;
@Data
public static class CommentFromTypeResult {
private Integer index;
private String title;
private String key;
}
}
}
}
}
\ No newline at end of file
package com.kwan.springbootkwan.entity.resp;
import java.io.Serializable;
import java.lang.Boolean;
import java.lang.Integer;
import java.lang.Object;
import java.lang.String;
public class ArticleInfo1 implements Serializable {
private String traceId;
private Integer code;
private Data data;
private String message;
public String getTraceId() {
return this.traceId;
}
public void setTraceId(String traceId) {
this.traceId = traceId;
}
public Integer getCode() {
return this.code;
}
public void setCode(Integer code) {
this.code = code;
}
public Data getData() {
return this.data;
}
public void setData(Data data) {
this.data = data;
}
public String getMessage() {
return this.message;
}
public void setMessage(String message) {
this.message = message;
}
public static class Data implements Serializable {
private Integer pageCount;
private Integer floorCount;
private Integer count;
private java.util.List<List> list;
private Integer foldCount;
public Integer getPageCount() {
return this.pageCount;
}
public void setPageCount(Integer pageCount) {
this.pageCount = pageCount;
}
public Integer getFloorCount() {
return this.floorCount;
}
public void setFloorCount(Integer floorCount) {
this.floorCount = floorCount;
}
public Integer getCount() {
return this.count;
}
public void setCount(Integer count) {
this.count = count;
}
public java.util.List<List> getList() {
return this.list;
}
public void setList(java.util.List<List> list) {
this.list = list;
}
public Integer getFoldCount() {
return this.foldCount;
}
public void setFoldCount(Integer foldCount) {
this.foldCount = foldCount;
}
public static class List implements Serializable {
private java.util.List<Sub> sub;
private Object pointCommentId;
private Sub info;
public java.util.List<Sub> getSub() {
return this.sub;
}
public void setSub(java.util.List<Sub> sub) {
this.sub = sub;
}
public Object getPointCommentId() {
return this.pointCommentId;
}
public void setPointCommentId(Object pointCommentId) {
this.pointCommentId = pointCommentId;
}
public Sub getInfo() {
return this.info;
}
public void setInfo(Sub info) {
this.info = info;
}
public static class Sub implements Serializable {
private Boolean flag;
private String dateFormat;
private String vipUrl;
private Object redEnvelopeInfo;
private Integer digg;
private String parentUserName;
private String content;
private Integer years;
private String parentNickName;
private Boolean loginUserDigg;
private String postTime;
private Boolean companyBlog;
private Boolean vip;
private String levelIcon;
private String orderNo;
private String companyBlogIcon;
private String nickName;
private Integer articleId;
private String flagIcon;
private String avatar;
private String userName;
private Integer parentId;
private String vipIcon;
private Boolean isBlack;
private Boolean isTop;
private Integer commentId;
private CommentFromTypeResult commentFromTypeResult;
private String region;
public Boolean getFlag() {
return this.flag;
}
public void setFlag(Boolean flag) {
this.flag = flag;
}
public String getDateFormat() {
return this.dateFormat;
}
public void setDateFormat(String dateFormat) {
this.dateFormat = dateFormat;
}
public String getVipUrl() {
return this.vipUrl;
}
public void setVipUrl(String vipUrl) {
this.vipUrl = vipUrl;
}
public Object getRedEnvelopeInfo() {
return this.redEnvelopeInfo;
}
public void setRedEnvelopeInfo(Object redEnvelopeInfo) {
this.redEnvelopeInfo = redEnvelopeInfo;
}
public Integer getDigg() {
return this.digg;
}
public void setDigg(Integer digg) {
this.digg = digg;
}
public String getParentUserName() {
return this.parentUserName;
}
public void setParentUserName(String parentUserName) {
this.parentUserName = parentUserName;
}
public String getContent() {
return this.content;
}
public void setContent(String content) {
this.content = content;
}
public Integer getYears() {
return this.years;
}
public void setYears(Integer years) {
this.years = years;
}
public String getParentNickName() {
return this.parentNickName;
}
public void setParentNickName(String parentNickName) {
this.parentNickName = parentNickName;
}
public Boolean getLoginUserDigg() {
return this.loginUserDigg;
}
public void setLoginUserDigg(Boolean loginUserDigg) {
this.loginUserDigg = loginUserDigg;
}
public String getPostTime() {
return this.postTime;
}
public void setPostTime(String postTime) {
this.postTime = postTime;
}
public Boolean getCompanyBlog() {
return this.companyBlog;
}
public void setCompanyBlog(Boolean companyBlog) {
this.companyBlog = companyBlog;
}
public Boolean getVip() {
return this.vip;
}
public void setVip(Boolean vip) {
this.vip = vip;
}
public String getLevelIcon() {
return this.levelIcon;
}
public void setLevelIcon(String levelIcon) {
this.levelIcon = levelIcon;
}
public String getOrderNo() {
return this.orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public String getCompanyBlogIcon() {
return this.companyBlogIcon;
}
public void setCompanyBlogIcon(String companyBlogIcon) {
this.companyBlogIcon = companyBlogIcon;
}
public String getNickName() {
return this.nickName;
}
public void setNickName(String nickName) {
this.nickName = nickName;
}
public Integer getArticleId() {
return this.articleId;
}
public void setArticleId(Integer articleId) {
this.articleId = articleId;
}
public String getFlagIcon() {
return this.flagIcon;
}
public void setFlagIcon(String flagIcon) {
this.flagIcon = flagIcon;
}
public String getAvatar() {
return this.avatar;
}
public void setAvatar(String avatar) {
this.avatar = avatar;
}
public String getUserName() {
return this.userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public Integer getParentId() {
return this.parentId;
}
public void setParentId(Integer parentId) {
this.parentId = parentId;
}
public String getVipIcon() {
return this.vipIcon;
}
public void setVipIcon(String vipIcon) {
this.vipIcon = vipIcon;
}
public Boolean getIsBlack() {
return this.isBlack;
}
public void setIsBlack(Boolean isBlack) {
this.isBlack = isBlack;
}
public Boolean getIsTop() {
return this.isTop;
}
public void setIsTop(Boolean isTop) {
this.isTop = isTop;
}
public Integer getCommentId() {
return this.commentId;
}
public void setCommentId(Integer commentId) {
this.commentId = commentId;
}
public CommentFromTypeResult getCommentFromTypeResult() {
return this.commentFromTypeResult;
}
public void setCommentFromTypeResult(CommentFromTypeResult commentFromTypeResult) {
this.commentFromTypeResult = commentFromTypeResult;
}
public String getRegion() {
return this.region;
}
public void setRegion(String region) {
this.region = region;
}
public static class CommentFromTypeResult implements Serializable {
private Integer index;
private String title;
private String key;
public Integer getIndex() {
return this.index;
}
public void setIndex(Integer index) {
this.index = index;
}
public String getTitle() {
return this.title;
}
public void setTitle(String title) {
this.title = title;
}
public String getKey() {
return this.key;
}
public void setKey(String key) {
this.key = key;
}
}
}
}
}
}
package com.kwan.springbootkwan.entity.resp; package com.kwan.springbootkwan.entity.resp;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.Data; import lombok.Data;
import java.util.List; import java.util.List;
@Data @Data
public class BusinessInfo { public class BusinessInfo {
private String traceId; private String traceId;
private Integer code; private Integer code;
private ArticleData data; private ArticleData data;
...@@ -14,16 +16,14 @@ public class BusinessInfo { ...@@ -14,16 +16,14 @@ public class BusinessInfo {
@Data @Data
public static class ArticleData { public static class ArticleData {
public Object total; public Object total;
@JsonProperty("list")
public List<Article> list; public List<Article> list;
@Data @Data
public static class Article { public static class Article {
public String formatTime; public String formatTime;
public Integer collectCount; public Integer collectCount;
public Integer source;
public String description; public String description;
public Integer diggCount; public Integer diggCount;
public String type; public String type;
...@@ -36,8 +36,29 @@ public class BusinessInfo { ...@@ -36,8 +36,29 @@ public class BusinessInfo {
public String editUrl; public String editUrl;
public Long createTime; public Long createTime;
public Integer articleType; public Integer articleType;
public List<String> picList; public List<Object> picList;
public Integer viewCount; public Integer viewCount;
public Object expandTitle;
public Object cover;
}
}
public static void main(String[] args) {
String body = " {\"code\":200,\"message\":\"success\",\"traceId\":\"56e59727-b0e5-4017-b613-3bfb9dbee864\",\"data\":{\"list\":[{\"type\":\"blog\",\"formatTime\":\"12 分钟前\",\"title\":\"【实战项目】从0到1实现高并发内存池(上)\",\"description\":\"\u200B本篇文章是实现一个高并发的内存池,他的原型是google的一个开源项目tcmalloc(tcmalloc源码),tcmalloc全称Thread-Caching Malloc,即线程缓存的malloc,是一种用于内存分配和管理的内存分配器(内存池)。这个项目旨在提高多线程应用程序的性能,实现了高效的多线程内存管理。\",\"hasOriginal\":true,\"diggCount\":4,\"commentCount\":3,\"postTime\":1698045098000,\"createTime\":1697553615000,\"url\":\"https://blog.csdn.net/weixin_67596609/article/details/133895730\",\"articleType\":1,\"viewCount\":36,\"picList\":[\"https://img-blog.csdnimg.cn/b7634b29af834f9d88cad6ba1de0258a.png\"],\"editUrl\":\"https://mp.csdn.net/console/editor/html/133895730\",\"collectCount\":3,\"rtype\":\"article\"},{\"type\":\"blink\",\"formatTime\":\"昨天 10:40\",\"title\":\"前几天由于一些原因,没有更新文章。最近要开始持续更新啦!\\nps:想多了全是问题,做多了全是答案!加油!\\n\",\"picList\":[{\"thumbnail\":\"https://userblink.csdnimg.cn/6748783d6e974f5da67346c6b0e9b2f0.png?x-oss-process=image/interlace,1/format,jpg/resize,w_375\",\"url\":\"https://userblink.csdnimg.cn/6748783d6e974f5da67346c6b0e9b2f0.png\"}],\"createTime\":1697942415000,\"url\":\"https://blink.csdn.net/details/1591445\",\"source\":1,\"expandTitle\":null,\"cover\":null,\"rtype\":\"picture\"}],\"total\":null}}";
ObjectMapper objectMapper = new ObjectMapper();
BusinessInfo businessInfo = null;
try {
businessInfo = objectMapper.readValue(body, BusinessInfo.class);
System.out.println(businessInfo);
} catch (JsonProcessingException e) {
e.printStackTrace();
} }
final BusinessInfo.ArticleData data = businessInfo.getData();
final List<BusinessInfo.ArticleData.Article> list = data.getList();
final BusinessInfo.ArticleData.Article article = list.get(0);
final String type = article.getType();
final String urlInfo = article.getUrl();
System.out.println(type);
System.out.println(urlInfo);
} }
} }
\ No newline at end of file
package com.kwan.springbootkwan.service; package com.kwan.springbootkwan.service;
import com.kwan.springbootkwan.entity.resp.BusinessInfo;
/** /**
* csdn博客自动化 * csdn博客自动化
* *
...@@ -13,7 +15,7 @@ public interface CsdnService { ...@@ -13,7 +15,7 @@ public interface CsdnService {
* *
* @return * @return
*/ */
String list(); BusinessInfo.ArticleData.Article list();
/** /**
* 查询是否评论过 * 查询是否评论过
......
...@@ -25,15 +25,17 @@ public class CsdnServiceImpl implements CsdnService { ...@@ -25,15 +25,17 @@ public class CsdnServiceImpl implements CsdnService {
private static final String CUSTOM_HEADER_VALUE = "uuid_tt_dd=10_20285116700-1697522872601-604163; c_adb=1; loginbox_strategy=%7B%22taskId%22%3A308%2C%22abCheckTime%22%3A1697522874474%2C%22version%22%3A%22control%22%7D; UserName=qyj19920704; UserInfo=a7d3b88c53a841ebb5792202cb43c84f; UserToken=a7d3b88c53a841ebb5792202cb43c84f; UserNick=%E6%AA%80%E8%B6%8A%E5%89%91%E6%8C%87%E5%A4%A7%E5%8E%82; AU=769; UN=qyj19920704; BT=1697522886100; p_uid=U010000; Hm_up_6bcd52f51e9b3dce32bec4a3997715ac=%7B%22islogin%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isonline%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isvip%22%3A%7B%22value%22%3A%220%22%2C%22scope%22%3A1%7D%2C%22uid_%22%3A%7B%22value%22%3A%22qyj19920704%22%2C%22scope%22%3A1%7D%7D; management_ques=1697592152734; blog_details_recommend_nps=1697616147423; c_segment=3; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1697522874,1697551027,1697636661,1697683407; csrfToken=jTRD3_1IBVA703lu2FkVkazx; dc_sid=9f7a02ed8375e91d86271ddaf1cf2ce4; c_first_ref=default; c_first_page=https%3A//liucy.blog.csdn.net/article/details/133852303%3Fspm%3D1001.2014.3001.5502; c_segment=3; Hm_lvt_e5ef47b9f471504959267fd614d579cd=1697764951; Hm_lpvt_e5ef47b9f471504959267fd614d579cd=1697764951; 404_page_nps=1697764955523; ssxmod_itna=YqUxBD97kOGHD8D2BmYite44zxcYo1=WOiox0vmvqGzDAxn40iDtgeqODDwu0/DNMQiDpiDuWOntaV73S5fd3iPeaN3D84i7DKqibDCqD1D3qDktzDYA8Dt4DTD34DYDiO=DBRsUQDFATN/3wUjmGtDG4DgDB=DxBEl3djBAq4DCr4DbxPy7mrDtLNSeLLdXT0/nn5Yf445SOG5lipwm0GdG7vwBA4PlDxNt8v1wADoGGGQYf+IE75ep753zpDxD; ssxmod_itna2=YqUxBD97kOGHD8D2BmYite44zxcYo1=WOYxn9EenDDsYebDLGQCoqQuGvHdDQRKYubdD6QqomsRD3xyRI/W9Q5nhe8oeYUvimaWYrNsqwcDgL6mDjYUhZK09LYcY/t5hSuP2va/kclf6hRkNh+LPyDwic73=9i4d94Lvw/R=oQ7E+jT4jjjA2Y+=QplLm8nbePRb+7=Re1CpjmZ4wIrnNPSKofWnIj=WOtkFtphylt+GhUxr0KkGtTzDXKDEEkbn3qhIn3Sj/ezt1u2MO3M9h7zEL6RunrXaKE+YdkRnIKiTG93cqpGFq8Fwr7ehksk1ZSWhoN2hQydddqQ1bTOSW8ddX+7g24v4TZ0+52=Y8PsOwfhavW4ECY8+GZOK=ro97bK0=Yi3YD5ZGsq25FhPodIRGCD2O8xidfo8+NR88v+rq4+b=fUOEK2frPEPdLFuYkao9uCfM1+cFZQ7q6HEMfRLjf6bhof0=1YhEYO1U=NZCPvDDw2Psluciq4De13mDNBODwqLwwg44qwOiDf=j1fKK5q+8gd7DDjKDeMv/04YDmLGvrwqOz4cov79500D4D==; c_first_ref=default; c_first_page=https%3A//mp.csdn.net/; creative_btn_mp=3; c_hasSub=true; write_guide_show=3; log_Id_click=177; dc_session_id=11_1698022100317.787671; c_dsid=11_1698022100317.794351; log_Id_pv=149; log_Id_view=1105; c_pref=https%3A//i.csdn.net/; c_ref=https%3A//blog.csdn.net/imwucx; c_page_id=default; dc_session_id=11_1698022100317.787671; c_dsid=11_1698022100317.794351; log_Id_view=1106; dc_tos=s2yi9b; log_Id_click=178; c_pref=https%3A//blog.csdn.net/imwucx; log_Id_pv=150; creativeSetApiNew=%7B%22toolbarImg%22%3Anull%2C%22publishSuccessImg%22%3Anull%2C%22articleNum%22%3A895%2C%22type%22%3A0%2C%22oldUser%22%3Afalse%2C%22useSeven%22%3Afalse%2C%22userName%22%3A%22qyj19920704%22%7D; c_ref=https%3A//cxian.blog.csdn.net/article/details/131299195; c_page_id=default; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1698022433; dc_tos=s2yinc"; private static final String CUSTOM_HEADER_VALUE = "uuid_tt_dd=10_20285116700-1697522872601-604163; c_adb=1; loginbox_strategy=%7B%22taskId%22%3A308%2C%22abCheckTime%22%3A1697522874474%2C%22version%22%3A%22control%22%7D; UserName=qyj19920704; UserInfo=a7d3b88c53a841ebb5792202cb43c84f; UserToken=a7d3b88c53a841ebb5792202cb43c84f; UserNick=%E6%AA%80%E8%B6%8A%E5%89%91%E6%8C%87%E5%A4%A7%E5%8E%82; AU=769; UN=qyj19920704; BT=1697522886100; p_uid=U010000; Hm_up_6bcd52f51e9b3dce32bec4a3997715ac=%7B%22islogin%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isonline%22%3A%7B%22value%22%3A%221%22%2C%22scope%22%3A1%7D%2C%22isvip%22%3A%7B%22value%22%3A%220%22%2C%22scope%22%3A1%7D%2C%22uid_%22%3A%7B%22value%22%3A%22qyj19920704%22%2C%22scope%22%3A1%7D%7D; management_ques=1697592152734; blog_details_recommend_nps=1697616147423; c_segment=3; Hm_lvt_6bcd52f51e9b3dce32bec4a3997715ac=1697522874,1697551027,1697636661,1697683407; csrfToken=jTRD3_1IBVA703lu2FkVkazx; dc_sid=9f7a02ed8375e91d86271ddaf1cf2ce4; c_first_ref=default; c_first_page=https%3A//liucy.blog.csdn.net/article/details/133852303%3Fspm%3D1001.2014.3001.5502; c_segment=3; Hm_lvt_e5ef47b9f471504959267fd614d579cd=1697764951; Hm_lpvt_e5ef47b9f471504959267fd614d579cd=1697764951; 404_page_nps=1697764955523; ssxmod_itna=YqUxBD97kOGHD8D2BmYite44zxcYo1=WOiox0vmvqGzDAxn40iDtgeqODDwu0/DNMQiDpiDuWOntaV73S5fd3iPeaN3D84i7DKqibDCqD1D3qDktzDYA8Dt4DTD34DYDiO=DBRsUQDFATN/3wUjmGtDG4DgDB=DxBEl3djBAq4DCr4DbxPy7mrDtLNSeLLdXT0/nn5Yf445SOG5lipwm0GdG7vwBA4PlDxNt8v1wADoGGGQYf+IE75ep753zpDxD; ssxmod_itna2=YqUxBD97kOGHD8D2BmYite44zxcYo1=WOYxn9EenDDsYebDLGQCoqQuGvHdDQRKYubdD6QqomsRD3xyRI/W9Q5nhe8oeYUvimaWYrNsqwcDgL6mDjYUhZK09LYcY/t5hSuP2va/kclf6hRkNh+LPyDwic73=9i4d94Lvw/R=oQ7E+jT4jjjA2Y+=QplLm8nbePRb+7=Re1CpjmZ4wIrnNPSKofWnIj=WOtkFtphylt+GhUxr0KkGtTzDXKDEEkbn3qhIn3Sj/ezt1u2MO3M9h7zEL6RunrXaKE+YdkRnIKiTG93cqpGFq8Fwr7ehksk1ZSWhoN2hQydddqQ1bTOSW8ddX+7g24v4TZ0+52=Y8PsOwfhavW4ECY8+GZOK=ro97bK0=Yi3YD5ZGsq25FhPodIRGCD2O8xidfo8+NR88v+rq4+b=fUOEK2frPEPdLFuYkao9uCfM1+cFZQ7q6HEMfRLjf6bhof0=1YhEYO1U=NZCPvDDw2Psluciq4De13mDNBODwqLwwg44qwOiDf=j1fKK5q+8gd7DDjKDeMv/04YDmLGvrwqOz4cov79500D4D==; c_first_ref=default; c_first_page=https%3A//mp.csdn.net/; creative_btn_mp=3; c_hasSub=true; write_guide_show=3; log_Id_click=177; dc_session_id=11_1698022100317.787671; c_dsid=11_1698022100317.794351; log_Id_pv=149; log_Id_view=1105; c_pref=https%3A//i.csdn.net/; c_ref=https%3A//blog.csdn.net/imwucx; c_page_id=default; dc_session_id=11_1698022100317.787671; c_dsid=11_1698022100317.794351; log_Id_view=1106; dc_tos=s2yi9b; log_Id_click=178; c_pref=https%3A//blog.csdn.net/imwucx; log_Id_pv=150; creativeSetApiNew=%7B%22toolbarImg%22%3Anull%2C%22publishSuccessImg%22%3Anull%2C%22articleNum%22%3A895%2C%22type%22%3A0%2C%22oldUser%22%3Afalse%2C%22useSeven%22%3Afalse%2C%22userName%22%3A%22qyj19920704%22%7D; c_ref=https%3A//cxian.blog.csdn.net/article/details/131299195; c_page_id=default; Hm_lpvt_6bcd52f51e9b3dce32bec4a3997715ac=1698022433; dc_tos=s2yinc";
@Override @Override
public String list() { public BusinessInfo.ArticleData.Article list() {
String url = "https://blog.csdn.net/community/home-api/v1/get-business-list"; String url = "https://blog.csdn.net/community/home-api/v1/get-business-list";
// 构建参数 // 构建参数
String username = "imwucx"; // String username = "imwucx";
// String username = "qq_40332045";
String username = "m0_69323023";
// 使用Hutool发送GET请求 // 使用Hutool发送GET请求
HttpResponse response = HttpUtil.createGet(url) HttpResponse response = HttpUtil.createGet(url)
.header(CUSTOM_HEADER_NAME, CUSTOM_HEADER_VALUE) // 添加自定义header参数 .header(CUSTOM_HEADER_NAME, CUSTOM_HEADER_VALUE) // 添加自定义header参数
.form("page", 1) .form("page", 1)
.form("size", 1) .form("size", 2)
.form("businessType", "lately") .form("businessType", "lately")
.form("noMore", false) .form("noMore", false)
.form("username", username) .form("username", username)
...@@ -53,8 +55,7 @@ public class CsdnServiceImpl implements CsdnService { ...@@ -53,8 +55,7 @@ public class CsdnServiceImpl implements CsdnService {
final BusinessInfo.ArticleData data = businessInfo.getData(); final BusinessInfo.ArticleData data = businessInfo.getData();
final List<BusinessInfo.ArticleData.Article> list = data.getList(); final List<BusinessInfo.ArticleData.Article> list = data.getList();
final BusinessInfo.ArticleData.Article article = list.get(0); final BusinessInfo.ArticleData.Article article = list.get(0);
final String urlInfo = article.getUrl(); return article;
return urlInfo.substring(urlInfo.lastIndexOf("/") + 1);
} }
@Override @Override
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册