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
49246ad4
Commit
49246ad4
authored
Jul 20, 2021
by
chenweitao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'working' into 'master'
新增淘宝日志 See merge request
!111
parents
84f3c094
809fe7cd
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
15 deletions
+17
-15
src/main/java/com/zhiwei/searchhotcrawler/crawler/TaoBaoHotSearchCrawler.java
+4
-2
src/main/java/com/zhiwei/searchhotcrawler/timer/quartz/GatherTimer.java
+13
-13
No files found.
src/main/java/com/zhiwei/searchhotcrawler/crawler/TaoBaoHotSearchCrawler.java
View file @
49246ad4
...
@@ -47,16 +47,18 @@ public class TaoBaoHotSearchCrawler {
...
@@ -47,16 +47,18 @@ public class TaoBaoHotSearchCrawler {
String
_m_h5_tk_enc
=
splitEnc
[
0
];
String
_m_h5_tk_enc
=
splitEnc
[
0
];
headerMap
.
put
(
"cookie"
,
_m_h5_tk
+
";"
+
_m_h5_tk_enc
);
headerMap
.
put
(
"cookie"
,
_m_h5_tk
+
";"
+
_m_h5_tk_enc
);
log
.
info
(
"获取cookie: {}"
,
_m_h5_tk
+
";"
+
_m_h5_tk_enc
);
log
.
info
(
"获取cookie: {}"
,
_m_h5_tk
+
";"
+
_m_h5_tk_enc
);
log
.
info
(
"获取响应结果: {}"
,
response
);
log
.
info
(
"获取
第一次
响应结果: {}"
,
response
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
log
.
error
(
"解析淘宝热搜时出现解析错误,页面结构有问题"
,
e
);
log
.
error
(
"解析淘宝热搜时出现解析错误,页面结构有问题"
,
e
);
}
}
String
signs
=
token
+
"&"
+
time
+
"&12574478&{\"appId\":\"10211\",\"params\":\"{\\\"multi_hintq_show\\\":\\\"on\\\",\\\"src\\\":\\\"c2c\\\",\\\"area\\\":\\\"active_page\\\",\\\"sversion\\\":\\\"7.5\\\",\\\"bangdan_src\\\":\\\"list\\\"}\"}"
;
String
signs
=
token
+
"&"
+
time
+
"&12574478&{\"appId\":\"10211\",\"params\":\"{\\\"multi_hintq_show\\\":\\\"on\\\",\\\"src\\\":\\\"c2c\\\",\\\"area\\\":\\\"active_page\\\",\\\"sversion\\\":\\\"7.5\\\",\\\"bangdan_src\\\":\\\"list\\\"}\"}"
;
String
sign
=
TaoBaoUtils
.
parsJSFunction
(
signs
);
String
sign
=
TaoBaoUtils
.
parsJSFunction
(
signs
);
String
url
=
"https://acs.m.taobao.com/h5/mtop.relationrecommend.wirelessrecommend.recommend/2.0/?appKey=12574478&t="
+
time
+
"&sign="
+
sign
+
"&api=mtop.relationrecommend.WirelessRecommend.recommend&v=2.0&type=jsonp&dataType=jsonp&callback=mtopjsonp1&data=%7B%22appId%22%3A%2210211%22%2C%22params%22%3A%22%7B%5C%22multi_hintq_show%5C%22%3A%5C%22on%5C%22%2C%5C%22src%5C%22%3A%5C%22c2c%5C%22%2C%5C%22area%5C%22%3A%5C%22active_page%5C%22%2C%5C%22sversion%5C%22%3A%5C%227.5%5C%22%2C%5C%22bangdan_src%5C%22%3A%5C%22list%5C%22%7D%22%7D"
;
String
url
=
"https://acs.m.taobao.com/h5/mtop.relationrecommend.wirelessrecommend.recommend/2.0/?appKey=12574478&t="
+
time
+
"&sign="
+
sign
+
"&api=mtop.relationrecommend.WirelessRecommend.recommend&v=2.0&type=jsonp&dataType=jsonp&callback=mtopjsonp1&data=%7B%22appId%22%3A%2210211%22%2C%22params%22%3A%22%7B%5C%22multi_hintq_show%5C%22%3A%5C%22on%5C%22%2C%5C%22src%5C%22%3A%5C%22c2c%5C%22%2C%5C%22area%5C%22%3A%5C%22active_page%5C%22%2C%5C%22sversion%5C%22%3A%5C%227.5%5C%22%2C%5C%22bangdan_src%5C%22%3A%5C%22list%5C%22%7D%22%7D"
;
log
.
info
(
"获取time: {}"
,
time
);
log
.
info
(
"获取sign: {}"
,
sign
);
Request
request
=
RequestUtils
.
wrapGet
(
url
,
headerMap
);
Request
request
=
RequestUtils
.
wrapGet
(
url
,
headerMap
);
try
(
Response
response
=
httpBoot
.
syncCall
(
request
,
ProxyHolder
.
NAT_HEAVY_PROXY
))
{
try
(
Response
response
=
httpBoot
.
syncCall
(
request
,
ProxyHolder
.
NAT_HEAVY_PROXY
))
{
log
.
info
(
"获取第二次请求访问结果: {}"
,
response
);
htmlBody
=
response
.
body
().
string
();
htmlBody
=
response
.
body
().
string
();
ht
=
!
htmlBody
.
contains
(
"非法请求"
);
ht
=
!
htmlBody
.
contains
(
"非法请求"
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
...
...
src/main/java/com/zhiwei/searchhotcrawler/timer/quartz/GatherTimer.java
View file @
49246ad4
...
@@ -520,17 +520,17 @@ public class GatherTimer {
...
@@ -520,17 +520,17 @@ public class GatherTimer {
TipsUtils
.
addHotList
(
HotSearchType
.
快手热榜
.
name
(),
kuaiShouList
);
TipsUtils
.
addHotList
(
HotSearchType
.
快手热榜
.
name
(),
kuaiShouList
);
logger
.
info
(
"快手热榜采集结束..."
);
logger
.
info
(
"快手热榜采集结束..."
);
}
}
//
/**
/**
//
*淘宝热搜采集
*淘宝热搜采集
//
*/
*/
//
@Async(value = "myScheduler")
@Async
(
value
=
"myScheduler"
)
//
@Scheduled(cron = "0 * * * * ? ")
@Scheduled
(
cron
=
"0 * * * * ? "
)
//
public void crawlerTaoBao(){
public
void
crawlerTaoBao
(){
//
logger.info("淘宝热搜开始采集...");
logger
.
info
(
"淘宝热搜开始采集..."
);
//
Date date = DateUtils.getMillSecondTime(new Date());
Date
date
=
DateUtils
.
getMillSecondTime
(
new
Date
());
//
List<HotSearchList> taoBaoList = TaoBaoHotSearchCrawler.taoBaoHotSearch(date);
List
<
HotSearchList
>
taoBaoList
=
TaoBaoHotSearchCrawler
.
taoBaoHotSearch
(
date
);
//
logger.info("{}, 淘宝热搜此轮采集到的数据量为:{}", new Date(), taoBaoList != null ? taoBaoList.size() : 0);
logger
.
info
(
"{}, 淘宝热搜此轮采集到的数据量为:{}"
,
new
Date
(),
taoBaoList
!=
null
?
taoBaoList
.
size
()
:
0
);
//
TipsUtils.addHotList(HotSearchType.淘宝热搜.name(), taoBaoList);
TipsUtils
.
addHotList
(
HotSearchType
.
淘宝热搜
.
name
(),
taoBaoList
);
//
logger.info("淘宝热搜采集结束...");
logger
.
info
(
"淘宝热搜采集结束..."
);
//
}
}
}
}
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