Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
weibohotcrawler
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
chenweiyang
weibohotcrawler
Commits
c1c96542
Commit
c1c96542
authored
Jul 01, 2019
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
新版本字段采集适配
parent
6110ef31
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
19 additions
and
16 deletions
+19
-16
pom.xml
+9
-4
src/main/java/com/zhiwei/weibocrawler/httpclient/HttpClientDemo.java
+6
-6
src/main/java/com/zhiwei/weibocrawler/rsidClient/RsidClientDAO.java
+4
-6
No files found.
pom.xml
View file @
c1c96542
...
@@ -3,7 +3,7 @@
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.zhiwei
</groupId>
<groupId>
com.zhiwei
</groupId>
<artifactId>
weibohotcrawler
</artifactId>
<artifactId>
weibohotcrawler
</artifactId>
<version>
0.0.
3
-SNAPSHOT
</version>
<version>
0.0.
4
-SNAPSHOT
</version>
<name>
weibohotcrawler
</name>
<name>
weibohotcrawler
</name>
<description>
微博热搜1小时榜单,社会、热点采集程序
</description>
<description>
微博热搜1小时榜单,社会、热点采集程序
</description>
...
@@ -22,15 +22,20 @@
...
@@ -22,15 +22,20 @@
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.zhiwei.middleware
</groupId>
<groupId>
com.zhiwei.middleware
</groupId>
<artifactId>
cleaner-unified-urlfilter
</artifactId>
<artifactId>
cleaner-unified-urlfilter
New
</artifactId>
<version>
1.0.0.RELEASE
</version>
<version>
0.0.5-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<dependency>
<groupId>
com.zhiwei.tools
</groupId>
<groupId>
com.zhiwei.tools
</groupId>
<artifactId>
zhiwei-tools
</artifactId>
<artifactId>
zhiwei-tools
</artifactId>
<version>
0.
0.5
-SNAPSHOT
</version>
<version>
0.
1.4
-SNAPSHOT
</version>
</dependency>
</dependency>
<dependency>
<groupId>
com.zhiwei.crawler
</groupId>
<artifactId>
crawler-core
</artifactId>
<version>
0.5.2-SNAPSHOT
</version>
</dependency>
</dependencies>
</dependencies>
<!-- 打包管理 -->
<!-- 打包管理 -->
<build>
<build>
...
...
src/main/java/com/zhiwei/weibocrawler/httpclient/HttpClientDemo.java
View file @
c1c96542
...
@@ -6,11 +6,15 @@ import java.util.Map;
...
@@ -6,11 +6,15 @@ import java.util.Map;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.zhiwei.tools.httpclient.HttpClientTemplateOK
;
import
com.zhiwei.crawler.core.HttpBoot
;
import
com.zhiwei.crawler.utils.RequestUtils
;
public
class
HttpClientDemo
{
public
class
HttpClientDemo
{
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
HttpClientDemo
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
HttpClientDemo
.
class
);
private
static
HttpBoot
httpBoot
=
new
HttpBoot
.
Builder
().
retryTimes
(
3
).
build
();
public
static
String
executeHttpRequestGet
(
String
url
)
{
public
static
String
executeHttpRequestGet
(
String
url
)
{
String
result
=
null
;
String
result
=
null
;
...
@@ -23,11 +27,7 @@ public class HttpClientDemo {
...
@@ -23,11 +27,7 @@ public class HttpClientDemo {
headerMap
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
headerMap
.
put
(
"Content-Type"
,
"application/x-www-form-urlencoded"
);
headerMap
.
put
(
"Host"
,
"weibo.com"
);
headerMap
.
put
(
"Host"
,
"weibo.com"
);
try
{
try
{
// Response response = HttpBoot.syncCall(RequestUtils.wrapGet(url, headerMap));
return
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headerMap
)).
body
().
string
();
// result = response.body().string();
result
=
HttpClientTemplateOK
.
get
(
url
,
null
,
headerMap
);
return
result
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
info
(
"httpClient 获取数据出现问题:{}"
,
e
.
getMessage
());
logger
.
info
(
"httpClient 获取数据出现问题:{}"
,
e
.
getMessage
());
e
.
printStackTrace
();
e
.
printStackTrace
();
...
...
src/main/java/com/zhiwei/weibocrawler/rsidClient/RsidClientDAO.java
View file @
c1c96542
...
@@ -4,8 +4,7 @@ import org.slf4j.Logger;
...
@@ -4,8 +4,7 @@ import org.slf4j.Logger;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
com.zhiwei.common.config.GroupType
;
import
com.zhiwei.common.config.GroupType
;
import
com.zhiwei.middleware.cleaner.ptenum.PTENUM
;
import
com.zhiwei.middleware.cleaner.urlfilter.UnifiedUrlFilterClientNew
;
import
com.zhiwei.middleware.cleaner.urlfilter.UnifiedUrlFilterClient
;
import
com.zhiwei.tools.tools.ZhiWeiTools
;
import
com.zhiwei.tools.tools.ZhiWeiTools
;
import
com.zhiwei.weibocrawler.config.Config
;
import
com.zhiwei.weibocrawler.config.Config
;
...
@@ -18,14 +17,14 @@ import com.zhiwei.weibocrawler.config.Config;
...
@@ -18,14 +17,14 @@ import com.zhiwei.weibocrawler.config.Config;
*/
*/
public
class
RsidClientDAO
{
public
class
RsidClientDAO
{
private
static
UnifiedUrlFilterClient
client
;
private
static
UnifiedUrlFilterClient
New
client
;
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
RsidClientDAO
.
class
);
private
static
Logger
logger
=
LoggerFactory
.
getLogger
(
RsidClientDAO
.
class
);
static
{
static
{
if
(
client
==
null
){
if
(
client
==
null
){
synchronized
(
RsidClientDAO
.
class
)
{
synchronized
(
RsidClientDAO
.
class
)
{
if
(
client
==
null
)
{
if
(
client
==
null
)
{
try
{
try
{
client
=
UnifiedUrlFilterClient
.
getClient
(
Config
.
rsidUrl
,
Config
.
rsidGroup
,
GroupType
.
PROVIDER
);
client
=
UnifiedUrlFilterClient
New
.
getClient
(
Config
.
rsidUrl
,
Config
.
rsidGroup
,
GroupType
.
PROVIDER
);
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"链接清洗中间件时出现错误,错误为:::{}"
,
e
);
logger
.
error
(
"链接清洗中间件时出现错误,错误为:::{}"
,
e
);
}
}
...
@@ -43,8 +42,7 @@ public class RsidClientDAO {
...
@@ -43,8 +42,7 @@ public class RsidClientDAO {
//循环3次避免连接超时引起的验证失效
//循环3次避免连接超时引起的验证失效
for
(
int
i
=
0
;
i
<
3
;
i
++){
for
(
int
i
=
0
;
i
<
3
;
i
++){
try
{
try
{
boolean
f
=
client
.
contains
(
mid
,
PTENUM
.
COMMON
);
return
client
.
uniqueContains
(
mid
);
return
f
;
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
logger
.
error
(
"判断此条微博消息是否存在出现问题"
,
e
.
fillInStackTrace
());
logger
.
error
(
"判断此条微博消息是否存在出现问题"
,
e
.
fillInStackTrace
());
ZhiWeiTools
.
sleep
(
200
);
ZhiWeiTools
.
sleep
(
200
);
...
...
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