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
7c54baf9
Commit
7c54baf9
authored
Dec 08, 2018
by
yangchen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加微信量 获取
parent
5429fc24
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
71 additions
and
0 deletions
+71
-0
src/main/java/com/zhiwei/wechat/search/WechatCount.java
+71
-0
No files found.
src/main/java/com/zhiwei/wechat/search/WechatCount.java
0 → 100644
View file @
7c54baf9
package
com
.
zhiwei
.
wechat
.
search
;
import
java.net.Proxy
;
import
java.net.URLEncoder
;
import
java.util.HashMap
;
import
java.util.Map
;
import
org.jsoup.Jsoup
;
import
org.jsoup.select.Elements
;
import
com.zhiwei.crawler.core.HttpBoot
;
import
com.zhiwei.crawler.core.RequestUtils
;
public
class
WechatCount
{
private
static
HttpBoot
httpBoot
=
new
HttpBoot
();
public
static
int
getWechatCountByWord
(
String
word
,
String
cookie
,
String
startTime
,
String
endTime
,
Proxy
proxy
)
{
Map
<
String
,
String
>
headerMap
=
getWechatCount
(
cookie
);
try
{
String
url
=
"http://weixin.sogou.com/weixin?type=2&ie=utf8&query="
+
URLEncoder
.
encode
(
word
,
"UTF-8"
)
+
"&tsn=5&ft="
+
startTime
.
split
(
" "
)[
0
]
+
"&et="
+
endTime
.
split
(
" "
)[
0
]
+
"&interation=&wxid=&usip="
;
headerMap
.
put
(
"Referer"
,
url
);
String
result
=
httpBoot
.
syncCall
(
RequestUtils
.
wrapGet
(
url
,
headerMap
),
proxy
)
.
body
().
string
();
String
s
=
""
;
int
n
=
-
1
;
if
(
result
.
contains
(
"找到约"
)
&&
result
.
contains
(
"条结果"
))
{
s
=
result
.
split
(
"找到约"
)[
1
].
split
(
"条结果"
)[
0
];
n
=
Integer
.
valueOf
(
s
.
replaceAll
(
","
,
""
));
}
Elements
elements
=
Jsoup
.
parse
(
result
).
select
(
"ul.news-list"
)
.
select
(
"li"
);
if
(
n
==
-
1
)
{
n
=
elements
.
size
();
}
return
n
;
}
catch
(
Exception
e
)
{
return
0
;
}
}
public
static
void
main
(
String
[]
args
)
{
String
cookie
=
"CXID=B4F6BF06873D2EFBC767B5EFF2747322; SUID=EAD6E7735E68860A5BF25BAB000EB028; SUV=0008470373E7D6EA5BF756F2BAF2D602; ABTEST=0|1543028023|v1; IPLOC=CN3302; weixinIndexVisited=1; ad=lFGL3Zllll2bDOmrlllllVZp2JyllllltMKQfkllllwlllllxp2PGK@@@@@@@@@@"
;
String
startTime
=
"2018-08-01 00:00:00"
;
String
endTime
=
"2018-08-02 00:00:00"
;
int
c
=
getWechatCountByWord
(
"唐嫣"
,
cookie
,
startTime
,
endTime
,
null
);
System
.
out
.
println
(
c
);
}
private
static
Map
<
String
,
String
>
getWechatCount
(
String
cookie
)
{
Map
<
String
,
String
>
headerMap
=
new
HashMap
<>();
headerMap
.
put
(
"User-Agent"
,
"Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36"
);
headerMap
.
put
(
"Accept"
,
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8"
);
headerMap
.
put
(
"Accept-Language"
,
"zh-CN,zh;q=0.9"
);
headerMap
.
put
(
"Connection"
,
"keep-alive"
);
headerMap
.
put
(
"Host"
,
"weixin.sogou.com"
);
if
(
cookie
!=
null
)
{
headerMap
.
put
(
"Cookie"
,
cookie
);
}
return
headerMap
;
}
}
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