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
81f2f704
Commit
81f2f704
authored
Oct 19, 2020
by
chenweitao
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'mlbWork' into 'master'
新浪热榜采集更新 See merge request
!49
parents
8a149923
e2f0cb6f
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
4 deletions
+13
-4
src/main/java/com/zhiwei/searchhotcrawler/crawler/XinLangHotSearchCrawler.java
+13
-4
No files found.
src/main/java/com/zhiwei/searchhotcrawler/crawler/XinLangHotSearchCrawler.java
View file @
81f2f704
...
@@ -8,6 +8,7 @@ import com.zhiwei.crawler.utils.RequestUtils;
...
@@ -8,6 +8,7 @@ import com.zhiwei.crawler.utils.RequestUtils;
import
com.zhiwei.searchhotcrawler.bean.HotSearchList
;
import
com.zhiwei.searchhotcrawler.bean.HotSearchList
;
import
com.zhiwei.searchhotcrawler.bean.HotSearchType
;
import
com.zhiwei.searchhotcrawler.bean.HotSearchType
;
import
com.zhiwei.searchhotcrawler.util.TipsUtils
;
import
com.zhiwei.searchhotcrawler.util.TipsUtils
;
import
com.zhiwei.tools.tools.URLCodeUtil
;
import
com.zhiwei.tools.tools.ZhiWeiTools
;
import
com.zhiwei.tools.tools.ZhiWeiTools
;
import
lombok.extern.log4j.Log4j2
;
import
lombok.extern.log4j.Log4j2
;
import
okhttp3.Request
;
import
okhttp3.Request
;
...
@@ -15,6 +16,7 @@ import okhttp3.Response;
...
@@ -15,6 +16,7 @@ import okhttp3.Response;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.jsoup.Jsoup
;
import
org.jsoup.Jsoup
;
import
org.jsoup.nodes.Document
;
import
org.jsoup.nodes.Document
;
import
org.jsoup.nodes.Element
;
import
org.jsoup.select.Elements
;
import
org.jsoup.select.Elements
;
import
java.io.IOException
;
import
java.io.IOException
;
...
@@ -43,9 +45,12 @@ public class XinLangHotSearchCrawler {
...
@@ -43,9 +45,12 @@ public class XinLangHotSearchCrawler {
}
}
if
(
htmlBody
!=
null
)
{
if
(
htmlBody
!=
null
)
{
Document
document
=
Jsoup
.
parse
(
htmlBody
);
Document
document
=
Jsoup
.
parse
(
htmlBody
);
String
html
=
document
.
getElementsByTag
(
"script"
).
last
().
html
();
Elements
elements
=
document
.
getElementsByTag
(
"script"
);
for
(
Element
element
:
elements
)
{
String
html
=
element
.
html
();
log
.
info
(
html
);
if
(
html
.
contains
(
"SM ="
))
{
jsonObject
=
JSONObject
.
parseObject
(
html
.
substring
(
html
.
indexOf
(
"{"
),
html
.
length
()
-
1
));
jsonObject
=
JSONObject
.
parseObject
(
html
.
substring
(
html
.
indexOf
(
"{"
),
html
.
length
()
-
1
));
// log.info(jsonObject);
JSONArray
jsonArray
=
jsonObject
.
getJSONObject
(
"data"
).
getJSONObject
(
"data"
).
getJSONArray
(
"result"
);
JSONArray
jsonArray
=
jsonObject
.
getJSONObject
(
"data"
).
getJSONObject
(
"data"
).
getJSONArray
(
"result"
);
if
(
jsonArray
!=
null
)
{
if
(
jsonArray
!=
null
)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
for
(
int
i
=
0
;
i
<
jsonArray
.
size
();
i
++)
{
...
@@ -56,9 +61,11 @@ public class XinLangHotSearchCrawler {
...
@@ -56,9 +61,11 @@ public class XinLangHotSearchCrawler {
String
showTags
=
jsonArray
.
getJSONObject
(
i
).
getString
(
"showTags"
);
String
showTags
=
jsonArray
.
getJSONObject
(
i
).
getString
(
"showTags"
);
String
routeUri
=
jsonArray
.
getJSONObject
(
i
).
getString
(
"routeUri"
);
String
routeUri
=
jsonArray
.
getJSONObject
(
i
).
getString
(
"routeUri"
);
String
xinLangUrl
=
null
;
String
xinLangUrl
=
null
;
if
(
routeUri
.
contains
(
"groupId"
))
{
if
(
routeUri
.
contains
(
"groupId"
))
{
xinLangUrl
=
"https://super.sina.cn/shequn/forum/detail_"
+
xinLangUrl
=
"https://super.sina.cn/shequn/forum/detail_"
+
routeUri
.
substring
(
routeUri
.
indexOf
(
"groupId="
)+
8
)
+
".html"
;
routeUri
.
substring
(
routeUri
.
indexOf
(
"groupId="
)
+
8
)
+
".html"
;
}
else
{
xinLangUrl
=
"https://m.so.com/s?q="
+
URLCodeUtil
.
getURLEncode
(
name
,
"utf-8"
)+
"&src=dfttrc&srcg=sina_shoulang_act"
;
}
}
String
icon
=
null
;
String
icon
=
null
;
if
(
showTags
.
contains
(
"新"
))
{
if
(
showTags
.
contains
(
"新"
))
{
...
@@ -76,6 +83,8 @@ public class XinLangHotSearchCrawler {
...
@@ -76,6 +83,8 @@ public class XinLangHotSearchCrawler {
return
hotSearchLists
;
return
hotSearchLists
;
}
}
}
}
}
}
ZhiWeiTools
.
sleep
(
3000L
);
ZhiWeiTools
.
sleep
(
3000L
);
}
}
return
hotSearchLists
;
return
hotSearchLists
;
...
...
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