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
dd0e065d
Commit
dd0e065d
authored
Jul 19, 2021
by
leiliangliang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新淘宝爬取程序
parent
75a499b6
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
15 deletions
+30
-15
pom.xml
+5
-0
src/main/java/com/zhiwei/searchhotcrawler/timer/quartz/GatherTimer.java
+13
-13
src/main/java/com/zhiwei/searchhotcrawler/util/TaoBaoUtils.java
+12
-2
No files found.
pom.xml
View file @
dd0e065d
...
...
@@ -124,6 +124,11 @@
<artifactId>
httpclient
</artifactId>
<version>
4.5.6
</version>
</dependency>
<dependency>
<groupId>
commons-io
</groupId>
<artifactId>
commons-io
</artifactId>
<version>
2.7
</version>
</dependency>
</dependencies>
...
...
src/main/java/com/zhiwei/searchhotcrawler/timer/quartz/GatherTimer.java
View file @
dd0e065d
...
...
@@ -520,17 +520,17 @@ public class GatherTimer {
TipsUtils
.
addHotList
(
HotSearchType
.
快手热榜
.
name
(),
kuaiShouList
);
logger
.
info
(
"快手热榜采集结束..."
);
}
//
/**
//
*淘宝热搜采集
//
*/
//
@Async(value = "myScheduler")
//
@Scheduled(cron = "0 * * * * ? ")
//
public void crawlerTaoBao(){
//
logger.info("淘宝热搜开始采集...");
//
Date date = DateUtils.getMillSecondTime(new Date());
//
List<HotSearchList> taoBaoList = TaoBaoHotSearchCrawler.taoBaoHotSearch(date);
//
logger.info("{}, 淘宝热搜此轮采集到的数据量为:{}", new Date(), taoBaoList != null ? taoBaoList.size() : 0);
//
TipsUtils.addHotList(HotSearchType.淘宝热搜.name(), taoBaoList);
//
logger.info("淘宝热搜采集结束...");
//
}
/**
*淘宝热搜采集
*/
@Async
(
value
=
"myScheduler"
)
@Scheduled
(
cron
=
"0 * * * * ? "
)
public
void
crawlerTaoBao
(){
logger
.
info
(
"淘宝热搜开始采集..."
);
Date
date
=
DateUtils
.
getMillSecondTime
(
new
Date
());
List
<
HotSearchList
>
taoBaoList
=
TaoBaoHotSearchCrawler
.
taoBaoHotSearch
(
date
);
logger
.
info
(
"{}, 淘宝热搜此轮采集到的数据量为:{}"
,
new
Date
(),
taoBaoList
!=
null
?
taoBaoList
.
size
()
:
0
);
TipsUtils
.
addHotList
(
HotSearchType
.
淘宝热搜
.
name
(),
taoBaoList
);
logger
.
info
(
"淘宝热搜采集结束..."
);
}
}
src/main/java/com/zhiwei/searchhotcrawler/util/TaoBaoUtils.java
View file @
dd0e065d
package
com
.
zhiwei
.
searchhotcrawler
.
util
;
import
lombok.extern.log4j.Log4j2
;
import
org.apache.commons.compress.utils.IOUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.springframework.core.io.ClassPathResource
;
import
org.springframework.core.io.Resource
;
import
javax.script.Invocable
;
import
javax.script.ScriptEngine
;
import
javax.script.ScriptEngineManager
;
import
java.io.File
;
import
java.io.FileReader
;
import
java.io.InputStream
;
@Log4j2
public
class
TaoBaoUtils
{
...
...
@@ -22,7 +25,14 @@ public class TaoBaoUtils {
//engine.eval(new StringReader(routeScript));
//如果js存在文件里
Resource
aesJs
=
new
ClassPathResource
(
"taobao.js"
);
engine
.
eval
(
new
FileReader
(
aesJs
.
getFile
()));
InputStream
inputStream
=
aesJs
.
getInputStream
();
File
somethingFile
=
File
.
createTempFile
(
"taobao"
,
".js"
);
try
{
FileUtils
.
copyInputStreamToFile
(
inputStream
,
somethingFile
);
}
finally
{
IOUtils
.
closeQuietly
(
inputStream
);
}
engine
.
eval
(
new
FileReader
(
somethingFile
));
//3.将引擎转换为Invocable,这样才可以掉用js的方法
Invocable
invocable
=
(
Invocable
)
engine
;
...
...
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