Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
searchhotcrawler
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
zhiwei
searchhotcrawler
Commits
353d295f
Commit
353d295f
authored
Jul 12, 2021
by
leiliangliang
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/working' into working
parents
c3901137
3d271f76
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
66 additions
and
2 deletions
+66
-2
src/main/java/com/zhiwei/searchhotcrawler/crawler/MaiMaiHotSearchCrawler.java
+4
-1
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
+8
-1
src/main/java/com/zhiwei/searchhotcrawler/util/MD5Util.java
+54
-0
No files found.
src/main/java/com/zhiwei/searchhotcrawler/crawler/MaiMaiHotSearchCrawler.java
View file @
353d295f
...
@@ -45,7 +45,10 @@ public class MaiMaiHotSearchCrawler {
...
@@ -45,7 +45,10 @@ public class MaiMaiHotSearchCrawler {
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
i
).
getJSONObject
(
"style35"
);
JSONObject
jsonObject
=
jsonArray
.
getJSONObject
(
i
).
getJSONObject
(
"style35"
);
if
(
jsonObject
!=
null
)
{
if
(
jsonObject
!=
null
)
{
String
name
=
jsonObject
.
getString
(
"text"
);
String
name
=
jsonObject
.
getString
(
"text"
);
log
.
info
(
name
);
if
(
name
.
length
()>
750
){
name
=
name
.
substring
(
0
,
750
);
}
// log.info(name);
String
maimaiUrl
=
jsonObject
.
getString
(
"share_url"
);
String
maimaiUrl
=
jsonObject
.
getString
(
"share_url"
);
String
icon
=
null
;
String
icon
=
null
;
if
(
jsonObject
.
containsKey
(
"hot_type_card"
))
{
if
(
jsonObject
.
containsKey
(
"hot_type_card"
))
{
...
...
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchCacheDAO.java
View file @
353d295f
...
@@ -6,12 +6,14 @@ import com.zhiwei.searchhotcrawler.bean.HotSearchList;
...
@@ -6,12 +6,14 @@ import com.zhiwei.searchhotcrawler.bean.HotSearchList;
import
com.zhiwei.searchhotcrawler.config.DBConfig
;
import
com.zhiwei.searchhotcrawler.config.DBConfig
;
import
com.zhiwei.searchhotcrawler.crawler.WeiboHotSearchCrawler
;
import
com.zhiwei.searchhotcrawler.crawler.WeiboHotSearchCrawler
;
import
com.zhiwei.searchhotcrawler.dbtemplate.MongoDBTemplate
;
import
com.zhiwei.searchhotcrawler.dbtemplate.MongoDBTemplate
;
import
com.zhiwei.searchhotcrawler.util.MD5Util
;
import
lombok.extern.log4j.Log4j2
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.logging.log4j.util.Strings
;
import
org.apache.logging.log4j.util.Strings
;
import
org.bson.Document
;
import
org.bson.Document
;
import
java.util.*
;
import
java.util.*
;
import
static
java
.
util
.
Objects
.
isNull
;
import
static
java
.
util
.
Objects
.
nonNull
;
import
static
java
.
util
.
Objects
.
nonNull
;
/**
/**
...
@@ -97,7 +99,12 @@ public class HotSearchCacheDAO {
...
@@ -97,7 +99,12 @@ public class HotSearchCacheDAO {
String
url
=
document
.
getString
(
"url"
)!=
null
?
document
.
getString
(
"url"
):
null
;
String
url
=
document
.
getString
(
"url"
)!=
null
?
document
.
getString
(
"url"
):
null
;
String
topicResult
=
document
.
getString
(
"topic_result"
)!=
null
?
document
.
getString
(
"topic_result"
):
null
;
String
topicResult
=
document
.
getString
(
"topic_result"
)!=
null
?
document
.
getString
(
"topic_result"
):
null
;
String
pictureUrl
=
document
.
getString
(
"pictureUrl"
)!=
null
?
document
.
getString
(
"pictureUrl"
):
null
;
String
pictureUrl
=
document
.
getString
(
"pictureUrl"
)!=
null
?
document
.
getString
(
"pictureUrl"
):
null
;
String
id
=
name
+
"_"
+
type
;
String
id
=
document
.
getString
(
"_id"
);
if
(
isNull
(
id
)){
id
=
name
+
"_"
+
type
;
}
boolean
recommend
=
false
;
boolean
recommend
=
false
;
// Integer readCount = document.getInteger("comment_count");
// Integer readCount = document.getInteger("comment_count");
if
(
"微博热搜"
.
equals
(
type
)){
if
(
"微博热搜"
.
equals
(
type
)){
...
...
src/main/java/com/zhiwei/searchhotcrawler/util/MD5Util.java
0 → 100644
View file @
353d295f
package
com
.
zhiwei
.
searchhotcrawler
.
util
;
import
java.security.MessageDigest
;
public
class
MD5Util
{
private
MD5Util
()
{
throw
new
IllegalStateException
(
"Utility class"
);
}
/**
* @Title: MD5
* @Description: MD5后的字符串
* @param pwd
* @param @return
* 设定文件
* @return String 返回类型
*/
public
static
String
getMD5
(
String
pwd
)
{
return
getString
(
pwd
);
}
private
static
String
getString
(
String
pwd
)
{
char
[]
md5String
=
{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'C'
,
'D'
,
'E'
,
'F'
};
try
{
// 使用平台的默认字符集将此 String 编码为 byte序列,并将结果存储到一个新的 byte数组中
byte
[]
btInput
=
pwd
.
getBytes
();
// 信息摘要是安全的单向哈希函数,它接收任意大小的数据,并输出固定长度的哈希值。
MessageDigest
mdInst
=
MessageDigest
.
getInstance
(
"MD5"
);
// MessageDigest对象通过使用 update方法处理数据, 使用指定的byte数组更新摘要
mdInst
.
update
(
btInput
);
// 摘要更新之后,通过调用digest()执行哈希计算,获得密文
byte
[]
md
=
mdInst
.
digest
();
// 把密文转换成十六进制的字符串形式
int
j
=
md
.
length
;
char
str
[]
=
new
char
[
j
*
2
];
int
k
=
0
;
for
(
int
i
=
0
;
i
<
j
;
i
++)
{
// i = 0
byte
byte0
=
md
[
i
];
// 95
str
[
k
++]
=
md5String
[
byte0
>>>
4
&
0xf
];
// 5
str
[
k
++]
=
md5String
[
byte0
&
0xf
];
// F
}
// 返回经过加密后的字符串
return
new
String
(
str
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
return
null
;
}
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment