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
5250248e
Commit
5250248e
authored
Mar 06, 2020
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
删除无用的log
parent
f5ffb595
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
134 additions
and
161 deletions
+134
-161
src/main/java/com/zhiwei/searchhotcrawler/config/Config.java
+40
-40
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchListDAO.java
+1
-3
src/main/java/com/zhiwei/searchhotcrawler/dao/WechatUserDao.java
+1
-4
src/main/java/com/zhiwei/searchhotcrawler/dao/WeiboSuperTopicDAO.java
+1
-3
src/main/java/com/zhiwei/searchhotcrawler/dbtemplate/MongoDBTemplate.java
+91
-91
src/main/java/com/zhiwei/searchhotcrawler/test/HotSearchListTest.java
+0
-19
src/main/java/com/zhiwei/searchhotcrawler/timer/WeiboTopicRun.java
+0
-1
No files found.
src/main/java/com/zhiwei/searchhotcrawler/config/Config.java
View file @
5250248e
package
com
.
zhiwei
.
searchhotcrawler
.
config
;
import
java.io.InputStream
;
import
java.util.Properties
;
public
class
Config
{
static
{
Properties
conf
=
null
;
try
{
InputStream
is
=
Thread
.
currentThread
().
getContextClassLoader
()
.
getResourceAsStream
(
"db.properties"
);
conf
=
new
Properties
();
conf
.
load
(
is
);
is
.
close
();
mongoIp
=
conf
.
getProperty
(
"mongoIp"
);
mongoPort
=
Integer
.
valueOf
(
conf
.
getProperty
(
"mongoPort"
));
userName
=
conf
.
getProperty
(
"db.username"
);
userPwd
=
conf
.
getProperty
(
"db.paasword"
);
authDB
=
conf
.
getProperty
(
"db.certifiedDB"
);
dbName
=
conf
.
getProperty
(
"dbName"
);
searchCollName
=
conf
.
getProperty
(
"searchCollName"
);
topicCollName
=
conf
.
getProperty
(
"topicCollName"
);
collWechatUserName
=
conf
.
getProperty
(
"collWechatUserName"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
static
String
mongoIp
;
public
static
int
mongoPort
;
public
static
String
userName
;
public
static
String
userPwd
;
public
static
String
authDB
;
public
static
String
dbName
;
public
static
String
searchCollName
;
public
static
String
topicCollName
;
public
static
String
collWechatUserName
;
}
package
com
.
zhiwei
.
searchhotcrawler
.
config
;
import
java.io.InputStream
;
import
java.util.Properties
;
public
class
Config
{
static
{
Properties
conf
=
null
;
try
{
InputStream
is
=
Thread
.
currentThread
().
getContextClassLoader
()
.
getResourceAsStream
(
"db.properties"
);
conf
=
new
Properties
();
conf
.
load
(
is
);
is
.
close
();
mongoIp
=
conf
.
getProperty
(
"mongoIp"
);
mongoPort
=
Integer
.
valueOf
(
conf
.
getProperty
(
"mongoPort"
));
userName
=
conf
.
getProperty
(
"db.username"
);
userPwd
=
conf
.
getProperty
(
"db.paasword"
);
authDB
=
conf
.
getProperty
(
"db.certifiedDB"
);
dbName
=
conf
.
getProperty
(
"dbName"
);
searchCollName
=
conf
.
getProperty
(
"searchCollName"
);
topicCollName
=
conf
.
getProperty
(
"topicCollName"
);
collWechatUserName
=
conf
.
getProperty
(
"collWechatUserName"
);
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
}
public
static
String
mongoIp
;
public
static
int
mongoPort
;
public
static
String
userName
;
public
static
String
userPwd
;
public
static
String
authDB
;
public
static
String
dbName
;
public
static
String
searchCollName
;
public
static
String
topicCollName
;
public
static
String
collWechatUserName
;
}
src/main/java/com/zhiwei/searchhotcrawler/dao/HotSearchListDAO.java
View file @
5250248e
...
...
@@ -6,16 +6,14 @@ import java.util.Date;
import
java.util.List
;
import
java.util.Objects
;
import
com.zhiwei.searchhotcrawler.config.Config
;
import
lombok.extern.log4j.Log4j2
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.DBCursor
;
import
com.mongodb.DBObject
;
import
com.zhiwei.searchhotcrawler.bean.HotSearchList
;
import
com.zhiwei.searchhotcrawler.cache.CacheManager
;
import
com.zhiwei.searchhotcrawler.config.Config
;
import
com.zhiwei.searchhotcrawler.dbtemplate.MongoDBTemplate
;
import
com.zhiwei.tools.timeparse.TimeParse
;
...
...
src/main/java/com/zhiwei/searchhotcrawler/dao/WechatUserDao.java
View file @
5250248e
...
...
@@ -3,14 +3,11 @@ package com.zhiwei.searchhotcrawler.dao;
import
java.util.Collections
;
import
java.util.List
;
import
com.zhiwei.searchhotcrawler.config.Config
;
import
lombok.extern.log4j.Log4j2
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.DBObject
;
import
com.zhiwei.searchhotcrawler.config.Config
;
import
com.zhiwei.searchhotcrawler.crawler.BaiDuHotSearchCrawler
;
import
com.zhiwei.searchhotcrawler.dbtemplate.MongoDBTemplate
;
@Log4j2
...
...
src/main/java/com/zhiwei/searchhotcrawler/dao/WeiboSuperTopicDAO.java
View file @
5250248e
...
...
@@ -5,13 +5,11 @@ import java.util.Date;
import
java.util.List
;
import
java.util.Objects
;
import
com.zhiwei.searchhotcrawler.config.Config
;
import
lombok.extern.log4j.Log4j2
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.DBObject
;
import
com.zhiwei.searchhotcrawler.config.Config
;
import
com.zhiwei.searchhotcrawler.dbtemplate.MongoDBTemplate
;
import
com.zhiwei.tools.timeparse.TimeParse
;
...
...
src/main/java/com/zhiwei/searchhotcrawler/dbtemplate/MongoDBTemplate.java
View file @
5250248e
package
com
.
zhiwei
.
searchhotcrawler
.
dbtemplate
;
import
java.util.Arrays
;
import
com.mongodb.DB
;
import
com.mongodb.DBCollection
;
import
com.mongodb.Mongo
;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoCredential
;
import
com.mongodb.MongoException
;
import
com.mongodb.ServerAddress
;
import
com.zhiwei.searchhotcrawler.config.Config
;
/**
*
* @Description: MongoDB模板类
* @author Tou Tang
* @date 2014-11-14 下午3:24:40
*/
public
class
MongoDBTemplate
{
protected
static
Mongo
reader
;
protected
static
Mongo
writer
;
protected
String
collName
;
protected
String
dbName
;
@SuppressWarnings
(
"deprecation"
)
public
MongoDBTemplate
()
{
try
{
MongoCredential
credential
=
MongoCredential
.
createCredential
(
Config
.
userName
,
Config
.
authDB
,
Config
.
userPwd
.
toCharArray
());
ServerAddress
address
=
new
ServerAddress
(
Config
.
mongoIp
,
Config
.
mongoPort
);
if
(
reader
==
null
)
{
reader
=
new
MongoClient
(
address
,
Arrays
.
asList
(
credential
));
// reader = new MongoClient(address);
}
if
(
writer
==
null
)
{
writer
=
new
MongoClient
(
address
,
Arrays
.
asList
(
credential
));
// writer = new MongoClient(address);
}
}
catch
(
MongoException
e
)
{
e
.
printStackTrace
();
}
}
public
DBCollection
getReadColl
()
{
@SuppressWarnings
(
"deprecation"
)
final
DB
db
=
getReader
().
getDB
(
dbName
);
final
DBCollection
coll
=
db
.
getCollection
(
collName
);
return
coll
;
}
protected
Mongo
getReader
()
{
return
reader
;
}
public
DBCollection
getWriteColl
()
{
@SuppressWarnings
(
"deprecation"
)
final
DB
db
=
getWriter
().
getDB
(
dbName
);
final
DBCollection
coll
=
db
.
getCollection
(
collName
);
return
coll
;
}
protected
Mongo
getWriter
()
{
return
writer
;
}
protected
void
setCollName
(
final
String
collName
)
{
this
.
collName
=
collName
;
}
protected
void
setDbName
(
final
String
dbName
)
{
this
.
dbName
=
dbName
;
}
@SuppressWarnings
(
"static-access"
)
protected
void
setReader
(
final
Mongo
reader
)
{
this
.
reader
=
reader
;
}
@SuppressWarnings
(
"static-access"
)
protected
void
setWriter
(
final
Mongo
writer
)
{
this
.
writer
=
writer
;
}
public
static
void
main
(
String
[]
args
)
{
}
}
package
com
.
zhiwei
.
searchhotcrawler
.
dbtemplate
;
import
java.util.Arrays
;
import
com.mongodb.DB
;
import
com.mongodb.DBCollection
;
import
com.mongodb.Mongo
;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoCredential
;
import
com.mongodb.MongoException
;
import
com.mongodb.ServerAddress
;
import
com.zhiwei.searchhotcrawler.config.Config
;
/**
*
* @Description: MongoDB模板类
* @author Tou Tang
* @date 2014-11-14 下午3:24:40
*/
public
class
MongoDBTemplate
{
protected
static
Mongo
reader
;
protected
static
Mongo
writer
;
protected
String
collName
;
protected
String
dbName
;
@SuppressWarnings
(
"deprecation"
)
public
MongoDBTemplate
()
{
try
{
MongoCredential
credential
=
MongoCredential
.
createCredential
(
Config
.
userName
,
Config
.
authDB
,
Config
.
userPwd
.
toCharArray
());
ServerAddress
address
=
new
ServerAddress
(
Config
.
mongoIp
,
Config
.
mongoPort
);
if
(
reader
==
null
)
{
reader
=
new
MongoClient
(
address
,
Arrays
.
asList
(
credential
));
// reader = new MongoClient(address);
}
if
(
writer
==
null
)
{
writer
=
new
MongoClient
(
address
,
Arrays
.
asList
(
credential
));
// writer = new MongoClient(address);
}
}
catch
(
MongoException
e
)
{
e
.
printStackTrace
();
}
}
public
DBCollection
getReadColl
()
{
@SuppressWarnings
(
"deprecation"
)
final
DB
db
=
getReader
().
getDB
(
dbName
);
final
DBCollection
coll
=
db
.
getCollection
(
collName
);
return
coll
;
}
protected
Mongo
getReader
()
{
return
reader
;
}
public
DBCollection
getWriteColl
()
{
@SuppressWarnings
(
"deprecation"
)
final
DB
db
=
getWriter
().
getDB
(
dbName
);
final
DBCollection
coll
=
db
.
getCollection
(
collName
);
return
coll
;
}
protected
Mongo
getWriter
()
{
return
writer
;
}
protected
void
setCollName
(
final
String
collName
)
{
this
.
collName
=
collName
;
}
protected
void
setDbName
(
final
String
dbName
)
{
this
.
dbName
=
dbName
;
}
@SuppressWarnings
(
"static-access"
)
protected
void
setReader
(
final
Mongo
reader
)
{
this
.
reader
=
reader
;
}
@SuppressWarnings
(
"static-access"
)
protected
void
setWriter
(
final
Mongo
writer
)
{
this
.
writer
=
writer
;
}
public
static
void
main
(
String
[]
args
)
{
}
}
src/main/java/com/zhiwei/searchhotcrawler/test/HotSearchListTest.java
View file @
5250248e
package
com
.
zhiwei
.
searchhotcrawler
.
test
;
import
java.util.ArrayList
;
import
java.util.Arrays
;
import
java.util.Date
;
import
java.util.List
;
import
java.util.Map
;
import
com.mongodb.BasicDBObject
;
import
com.mongodb.DB
;
import
com.mongodb.DBCollection
;
import
com.mongodb.DBCursor
;
import
com.mongodb.DBObject
;
import
com.mongodb.Mongo
;
import
com.mongodb.MongoClient
;
import
com.mongodb.MongoCredential
;
import
com.mongodb.ServerAddress
;
import
com.mongodb.WriteResult
;
import
com.zhiwei.crawler.core.HttpBoot
;
import
com.zhiwei.crawler.proxy.ProxyFactory
;
import
com.zhiwei.crawler.proxy.ProxyHolder
;
import
com.zhiwei.crawler.utils.RequestUtils
;
import
com.zhiwei.proxy.config.SimpleConfig
;
import
com.zhiwei.searchhotcrawler.bean.HotSearchType
;
import
com.zhiwei.searchhotcrawler.config.Config
;
import
com.zhiwei.searchhotcrawler.config.ProxyConfig
;
import
com.zhiwei.tools.timeparse.TimeParse
;
import
org.jsoup.Jsoup
;
import
org.jsoup.nodes.Element
;
import
org.jsoup.select.Elements
;
...
...
src/main/java/com/zhiwei/searchhotcrawler/timer/WeiboTopicRun.java
View file @
5250248e
...
...
@@ -37,7 +37,6 @@ public class WeiboTopicRun extends Thread{
log
.
info
(
"{}, 微博话题此轮采集到的数据量为:{}"
,
new
Date
(),
Integer
.
valueOf
(
list
!=
null
?
list
.
size
()
:
0
));
List
<
DBObject
>
data
=
new
ArrayList
<>();
for
(
HotSearchList
topic
:
list
){
log
.
info
(
"topic::::{}"
,
topic
);
DBObject
doc
=
new
BasicDBObject
();
doc
.
put
(
"_id"
,
topic
.
getId
());
doc
.
put
(
"name"
,
topic
.
getName
());
...
...
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