Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wechat
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
wechat
Commits
eec30e53
Commit
eec30e53
authored
Nov 09, 2019
by
zhiwei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
将转临时链接的重试修改带外部,有调用jar的人实现
parent
cedeeab7
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
29 deletions
+18
-29
pom.xml
+1
-1
src/main/java/com/zhiwei/wechat/search/WechatReal.java
+17
-28
No files found.
pom.xml
View file @
eec30e53
...
...
@@ -3,7 +3,7 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
com.zhiwei
</groupId>
<artifactId>
wechat
</artifactId>
<version>
1.2.
8
-SNAPSHOT
</version>
<version>
1.2.
9
-SNAPSHOT
</version>
<description>
知微微信采集程序,包含
1.微信历史文章采集
...
...
src/main/java/com/zhiwei/wechat/search/WechatReal.java
View file @
eec30e53
...
...
@@ -38,12 +38,9 @@ public class WechatReal {
return
realUrl
;
}
/**
* 获取真实链接
* @param originalUrl
* @return
* @throws Exception
*/
private
static
String
getFinalUrl
(
String
originalUrl
,
Proxy
proxy
)
throws
Exception
{
Map
<
String
,
String
>
headerMap
=
new
HashMap
<>();
headerMap
.
put
(
"Sec-Fetch-Mode"
,
"navigate"
);
...
...
@@ -55,30 +52,22 @@ public class WechatReal {
String
word
=
originalUrl
.
split
(
"query="
)[
1
];
String
searchUrl
=
"https://weixin.sogou.com/weixin?query="
+
word
;
for
(
int
i
=
0
;
i
<
3
;
i
++){
try
{
headerMap
.
put
(
"referer"
,
searchUrl
);
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
searchUrl
,
headerMap
),
proxy
).
body
().
string
();
headerMap
.
put
(
"referer"
,
searchUrl
);
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
searchUrl
,
headerMap
),
proxy
).
body
().
string
();
String
htmlBody
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
originalUrl
,
headerMap
),
proxy
).
body
().
string
();
headerMap
.
put
(
"referer"
,
searchUrl
);
if
(
StringUtils
.
isNotBlank
(
htmlBody
)
&&
!
htmlBody
.
contains
(
"验证码"
)){
StringBuilder
furl
=
new
StringBuilder
();
Pattern
pa1
=
Pattern
.
compile
(
"url \\+= \'(.*?)\';"
);
Matcher
ma1
=
pa1
.
matcher
(
htmlBody
);
while
(
ma1
.
find
())
{
furl
.
append
(
ma1
.
group
(
1
));
}
return
furl
.
toString
();
}
}
catch
(
Exception
e
){
if
(
i
==
2
){
throw
e
;
}
continue
;
String
htmlBody
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
originalUrl
,
headerMap
),
proxy
).
body
().
string
();
headerMap
.
put
(
"referer"
,
searchUrl
);
if
(
StringUtils
.
isNotBlank
(
htmlBody
)
&&
!
htmlBody
.
contains
(
"验证码"
)){
StringBuilder
furl
=
new
StringBuilder
();
Pattern
pa1
=
Pattern
.
compile
(
"url \\+= \'(.*?)\';"
);
Matcher
ma1
=
pa1
.
matcher
(
htmlBody
);
while
(
ma1
.
find
())
{
furl
.
append
(
ma1
.
group
(
1
));
}
return
furl
.
toString
();
}
else
{
throw
new
NullPointerException
(
"获取临时链接失败"
);
}
return
null
;
}
}
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