-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
<li>Aop操作Redis(find ? [get redis] : [push redis and return] )</li> <li>强大的代码生成器,部分通用代码通过配置,直接生成,方便的不要不要的</li> <li>JSON在线序列化,基佬在也不用担心截图的JSON不整齐了</li> <li>新浪微博,博主发帖评论的爬虫抓取,各位客官悠着点别被封IP了</li> <li>强大的Mycat,数据库中间件,Solr搜索查询,玩命开发中.....</li> <li>Spring大家族的SpringFOX在线文档,目前未提供生成静态的.卖命开发中...</li>
- Loading branch information
memmsc
committed
Oct 18, 2016
1 parent
57bad40
commit 38cad70
Showing
97 changed files
with
40,367 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package com.battcn.framework; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.web.servlet.config.annotation.EnableWebMvc; | ||
import springfox.documentation.service.ApiInfo; | ||
import springfox.documentation.service.Contact; | ||
import springfox.documentation.spi.DocumentationType; | ||
import springfox.documentation.spring.web.plugins.Docket; | ||
import springfox.documentation.swagger2.annotations.EnableSwagger2; | ||
|
||
@Configuration | ||
@EnableWebMvc | ||
@EnableSwagger2 | ||
@ComponentScan(basePackages = {"com.battcn.platform.controller" }) | ||
public class SwaggerConfig | ||
{ | ||
@Bean | ||
public Docket customDocket() | ||
{ | ||
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()); | ||
} | ||
|
||
private ApiInfo apiInfo() | ||
{ | ||
ApiInfo apiInfo = new ApiInfo("Battcn接口文档", "Battcn是鏖战八方的一个开源项目,里面的内容包含框架,工具,适合新手以及刚工作不久的人,希望能帮助到大家", | ||
"battcn2.0", "My Apps API terms of service", | ||
new Contact("鏖战八方", "http://www.battcn.com", "[email protected]"), "加入我们", "http://www.battcn.com"); | ||
return apiInfo; | ||
} | ||
} |
119 changes: 119 additions & 0 deletions
119
src/main/java/com/battcn/framework/jsoup/sina/SinaInitMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
package com.battcn.framework.jsoup.sina; | ||
|
||
import java.io.BufferedReader; | ||
import java.io.InputStreamReader; | ||
import java.net.HttpURLConnection; | ||
import java.net.URL; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.jsoup.Jsoup; | ||
import org.jsoup.nodes.Document; | ||
import org.jsoup.nodes.Element; | ||
import org.jsoup.select.Elements; | ||
|
||
import com.alibaba.fastjson.JSON; | ||
import com.alibaba.fastjson.JSONObject; | ||
|
||
/** | ||
* @ClassName: SinaInitMethod | ||
* @author 唐亚峰 | ||
* @date 2016年10月17日 | ||
*/ | ||
public class SinaInitMethod | ||
{ | ||
|
||
/** | ||
* 接口调用 GET | ||
*/ | ||
public static String getSinaReview(String urlStr,String cookie) | ||
{ | ||
StringBuilder sb = new StringBuilder(); | ||
try | ||
{ | ||
URL url = new URL(urlStr); // 把字符串转换为URL请求地址 | ||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();// 打开连接 | ||
connection.setRequestProperty("Connection", "keep-alive"); | ||
connection.setRequestProperty("Cookie",cookie); | ||
connection.connect();// 连接会话 | ||
// 获取输入流 | ||
BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream())); | ||
String line; | ||
|
||
while ((line = br.readLine()) != null) | ||
{// 循环读取流 | ||
sb.append(line); | ||
} | ||
br.close();// 关闭流 | ||
connection.disconnect();// 断开连接 | ||
} catch (Exception e) | ||
{ | ||
e.printStackTrace(); | ||
System.out.println("失败!"); | ||
} | ||
return sb.toString(); | ||
} | ||
|
||
public static List<SinaReview> sina(String id,int page,String cookie) | ||
{ | ||
//这里的地址,需要玩爬虫的自己去找个微博博主的微博点开就有了,为了被封号 我肯定不敢吧自己的提供给你们,Cookie会开发的都会用浏览器Copy出来O(∩_∩)O哈哈~ | ||
String url = "http://weibo.com/aj/v6/comment/big?ajwvr=6&id="+id+"&page=" + page; | ||
String review = getSinaReview(url,cookie); | ||
JSONObject json = JSON.parseObject(review); | ||
JSONObject data = json.getJSONObject("data"); | ||
// System.out.println(data); | ||
// Integer count = data.getInteger("count"); | ||
// JSONObject page = data.getJSONObject("page"); | ||
// Integer pageNum = page.getInteger("pagenum"); | ||
// Integer totalPage = page.getInteger("totalpage"); | ||
String html = data.getString("html"); | ||
Document doc = Jsoup.parse(html); | ||
Elements ee = doc.getElementsByAttribute("comment_id"); | ||
List<SinaReview> list = new ArrayList<SinaReview>(); | ||
SinaReview sinaReview = null; | ||
for (Element el : ee) | ||
{ | ||
sinaReview = new SinaReview(); | ||
String commentId = Jsoup.parse(el.outerHtml()).getElementsByTag("div").attr("comment_id"); | ||
Element efl = el.getElementsByClass("W_fl").first(); | ||
String commentUrl = efl.getElementsByTag("a").attr("abs:href"); | ||
String image = efl.getElementsByTag("img").attr("src"); | ||
String userCard = efl.getElementsByTag("img").attr("usercard"); | ||
String comment = el.getElementsByClass("WB_text").first().text(); | ||
sinaReview.setBlog("邓超"); | ||
sinaReview.setCommentId(commentId); | ||
sinaReview.setCommentUrl(commentUrl); | ||
sinaReview.setComment(comment); | ||
sinaReview.setImage(image); | ||
sinaReview.setTitle("从你的全世界路过"); | ||
sinaReview.setUserCard(userCard); | ||
list.add(sinaReview); | ||
} | ||
return list; | ||
} | ||
|
||
public void init() | ||
{ | ||
Thread thread = new Thread(new Runnable() | ||
{ | ||
@Override | ||
public void run() | ||
{ | ||
/*MybatisSqlDao mybatisSqlDao = (MybatisSqlDao) AppContextUtil.getBean("mybatisSqlDaoImpl"); | ||
for (int i = 1; i < 956; i++) | ||
{ | ||
List<SinaReview> list = sina("1111111111111111",i,"cookie"); | ||
if (list != null && list.size() > 0) | ||
try | ||
{ | ||
mybatisSqlDao.batchSave("com.battcn.platform.mapper.sina.SinaMapper.batchAddSina", list); | ||
} catch (Exception e) | ||
{ | ||
System.out.println("[error] - [批量添加错误] - [错误信息:]"+e.getMessage()); | ||
} | ||
}*/ | ||
} | ||
}); | ||
thread.start(); | ||
} | ||
} |
112 changes: 112 additions & 0 deletions
112
src/main/java/com/battcn/framework/jsoup/sina/SinaReview.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
package com.battcn.framework.jsoup.sina; | ||
|
||
import java.util.Date; | ||
|
||
/** | ||
* @ClassName: SinaReview | ||
* @author 唐亚峰 | ||
* @date 2016年10月14日 | ||
*/ | ||
public class SinaReview | ||
{ | ||
private Long id; | ||
private String blog;// 博主 | ||
private String title;// 标题 | ||
private String commentId;// 公共的微博ID | ||
private String commentUrl;// 用户微博地址 | ||
private String userCard;// 用户标示 | ||
private String image;// 微博用户的头像 | ||
private String comment;// 微博用户的留言 | ||
private Date date; | ||
|
||
public Long getId() | ||
{ | ||
return id; | ||
} | ||
|
||
public void setId(Long id) | ||
{ | ||
this.id = id; | ||
} | ||
|
||
public String getBlog() | ||
{ | ||
return blog; | ||
} | ||
|
||
public void setBlog(String blog) | ||
{ | ||
this.blog = blog; | ||
} | ||
|
||
public String getTitle() | ||
{ | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) | ||
{ | ||
this.title = title; | ||
} | ||
|
||
public String getCommentId() | ||
{ | ||
return commentId; | ||
} | ||
|
||
public void setCommentId(String commentId) | ||
{ | ||
this.commentId = commentId; | ||
} | ||
|
||
public String getCommentUrl() | ||
{ | ||
return commentUrl; | ||
} | ||
|
||
public void setCommentUrl(String commentUrl) | ||
{ | ||
this.commentUrl = commentUrl; | ||
} | ||
|
||
public String getUserCard() | ||
{ | ||
return userCard; | ||
} | ||
|
||
public void setUserCard(String userCard) | ||
{ | ||
this.userCard = userCard; | ||
} | ||
|
||
public String getImage() | ||
{ | ||
return image; | ||
} | ||
|
||
public void setImage(String image) | ||
{ | ||
this.image = image; | ||
} | ||
|
||
public String getComment() | ||
{ | ||
return comment; | ||
} | ||
|
||
public void setComment(String comment) | ||
{ | ||
this.comment = comment; | ||
} | ||
|
||
public Date getDate() | ||
{ | ||
return date; | ||
} | ||
|
||
public void setDate(Date date) | ||
{ | ||
this.date = date; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.