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
7577a1fa
Commit
7577a1fa
authored
Sep 16, 2022
by
chenweitao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'working' into 'master'
Working See merge request
!203
parents
fe68bfbe
e4f4c636
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
127 additions
and
1 deletions
+127
-1
src/main/java/com/zhiwei/searchhotcrawler/bean/IconEnum.java
+117
-0
src/main/java/com/zhiwei/searchhotcrawler/crawler/WeiboHotSearchCrawler.java
+10
-1
No files found.
src/main/java/com/zhiwei/searchhotcrawler/bean/IconEnum.java
0 → 100644
View file @
7577a1fa
package
com
.
zhiwei
.
searchhotcrawler
.
bean
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
java.util.Arrays
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
* 类型枚举
* @author
* @date
*/
public
enum
IconEnum
{
/** icon图标转换 */
公益
(
"jian_gongyi"
,
"益"
,
"蓝色"
,
"https://simg.s.weibo.com/20211014_jian_gongyi.png"
),
推荐
(
"recom_yellow"
,
"荐"
,
"黄色"
,
"https://simg.s.weibo.com/20200925_recom_yellow.png"
),
爆
(
"boom"
,
"爆"
,
"深红色"
,
"https://simg.s.weibo.com/20210226_boom.png"
),
沸
(
"fei"
,
"沸"
,
"深橙色"
,
"https://simg.s.weibo.com/20210226_fei.png"
),
热
(
"hot"
,
"热"
,
"橙色"
,
"https://simg.s.weibo.com/20210226_hot.png"
),
新
(
"new"
,
"新"
,
"红色"
,
"https://simg.s.weibo.com/20210226_new.png"
),
商
(
"jian"
,
"商"
,
"蓝色"
,
"https://simg.s.weibo.com/20210623_jian.png"
),
首发
(
"free_issue"
,
"首发"
,
"蓝色"
,
"https://simg.s.weibo.com/20220424_search_ads_%E9%A6%96%E5%8F%91.png"
),
预约
(
"appointment"
,
"预约"
,
"蓝色"
,
"https://simg.s.weibo.com/20220424_search_ads_%E9%A2%84%E7%BA%A6.png"
),
官宣
(
"Officer_xuan"
,
"官宣"
,
"蓝色"
,
"https://simg.s.weibo.com/20220424_search_ads_%E5%AE%98%E5%AE%A3.png"
),
上新
(
"newest"
,
"上新"
,
"蓝色"
,
"https://simg.s.weibo.com/20220424_search_ads_%E4%B8%8A%E6%96%B0.png"
),
;
private
static
Logger
logger
=
LogManager
.
getLogger
(
IconEnum
.
class
.
getName
());
IconEnum
(
String
name
,
String
describe
,
String
color
,
String
iconUrl
)
{
this
.
name
=
name
;
this
.
describe
=
describe
;
this
.
color
=
color
;
this
.
iconUrl
=
iconUrl
;
}
/** 图标名 */
private
String
name
;
/** 图标描述 */
private
String
describe
;
/** 图标背景色 */
private
String
color
;
/** 图标地址链接 */
private
String
iconUrl
;
/**
* k name
* v describe
* 根据名获取
**/
static
Map
<
String
,
String
>
nameDescribeMap
;
static
{
nameDescribeMap
=
Arrays
.
stream
(
IconEnum
.
values
()).
collect
(
Collectors
.
toMap
(
IconEnum:
:
getName
,
IconEnum:
:
getDescribe
,
(
k1
,
k2
)
->
k1
));
}
/**
* 图标名转换成描述
*
* @param name
* @return
*/
public
String
nameChangeDescribe
(
String
name
)
{
if
(
nameDescribeMap
.
containsKey
(
name
))
{
return
nameDescribeMap
.
get
(
name
);
}
else
{
logger
.
error
(
"未找到相应图标描述,name={}"
,
name
);
return
null
;
}
}
public
String
getName
()
{
return
name
;
}
public
void
setName
(
String
name
)
{
this
.
name
=
name
;
}
public
String
getDescribe
()
{
return
describe
;
}
public
void
setDescribe
(
String
describe
)
{
this
.
describe
=
describe
;
}
public
String
getColor
()
{
return
color
;
}
public
void
setColor
(
String
color
)
{
this
.
color
=
color
;
}
public
String
getIconUrl
()
{
return
iconUrl
;
}
public
void
setIconUrl
(
String
iconUrl
)
{
this
.
iconUrl
=
iconUrl
;
}
@Override
public
String
toString
()
{
return
"IconEnum{"
+
"name='"
+
name
+
'\''
+
", describe='"
+
describe
+
'\''
+
", color='"
+
color
+
'\''
+
", iconUrl='"
+
iconUrl
+
'\''
+
'}'
;
}
}
src/main/java/com/zhiwei/searchhotcrawler/crawler/WeiboHotSearchCrawler.java
View file @
7577a1fa
...
@@ -2,6 +2,7 @@ package com.zhiwei.searchhotcrawler.crawler;
...
@@ -2,6 +2,7 @@ package com.zhiwei.searchhotcrawler.crawler;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.UnsupportedEncodingException
;
import
java.io.UnsupportedEncodingException
;
import
java.net.URLDecoder
;
import
java.net.URLEncoder
;
import
java.net.URLEncoder
;
import
java.text.ParseException
;
import
java.text.ParseException
;
import
java.text.SimpleDateFormat
;
import
java.text.SimpleDateFormat
;
...
@@ -309,7 +310,15 @@ public class WeiboHotSearchCrawler {
...
@@ -309,7 +310,15 @@ public class WeiboHotSearchCrawler {
String
iconUrl
=
cardInfo
.
getString
(
"icon"
);
String
iconUrl
=
cardInfo
.
getString
(
"icon"
);
String
icon
=
null
;
String
icon
=
null
;
if
(
StringUtils
.
isNotBlank
(
iconUrl
))
{
if
(
StringUtils
.
isNotBlank
(
iconUrl
))
{
icon
=
iconUrl
.
split
(
"_"
)[
1
].
split
(
".png"
)[
0
];
String
[]
iconString
=
iconUrl
.
split
(
"_"
);
if
(
iconString
.
length
==
4
){
icon
=
iconString
[
3
].
split
(
".png"
)[
0
];
icon
=
URLDecoder
.
decode
(
icon
,
"utf-8"
);
}
else
if
(
iconString
.
length
==
3
){
icon
=
iconString
[
1
]+
"_"
+
iconString
[
2
].
split
(
".png"
)[
0
];
}
else
{
icon
=
iconString
[
1
].
split
(
".png"
)[
0
];
}
}
}
// String id = "http://s.weibo.com/weibo/" + URLCodeUtil.getURLEncode(name, "utf-8") + "&Refer=top";
// String id = "http://s.weibo.com/weibo/" + URLCodeUtil.getURLEncode(name, "utf-8") + "&Refer=top";
String
id
=
cardInfo
.
getString
(
"scheme"
);
String
id
=
cardInfo
.
getString
(
"scheme"
);
...
...
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