Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
crawler_store
Project
Project
Details
Activity
Releases
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
litianle
crawler_store
Commits
7e3262e5
Commit
7e3262e5
authored
Mar 19, 2022
by
litianle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
添加711
parent
074bac95
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
74 additions
and
5 deletions
+74
-5
FamilyMartCrawler.java
...crawler/modules/familyMart/crawler/FamilyMartCrawler.java
+7
-5
SevenElevenCrawler.java
...wler/modules/seven_Eleven/crawler/SevenElevenCrawler.java
+52
-0
Store.java
...a/com/deeprec/crawler/modules/seven_Eleven/dto/Store.java
+15
-0
No files found.
src/main/java/com/deeprec/crawler/modules/familyMart/crawler/FamilyMartCrawler.java
View file @
7e3262e5
...
@@ -20,7 +20,7 @@ public class FamilyMartCrawler {
...
@@ -20,7 +20,7 @@ public class FamilyMartCrawler {
private
static
final
String
SK_NAME
=
"全家"
;
private
static
final
String
SK_NAME
=
"全家"
;
private
static
final
String
URL
=
"http://www.familymart.com.cn/store"
;
private
static
final
String
URL
=
"http://www.familymart.com.cn/store"
;
private
static
final
Map
<
String
,
String
>
city
s
=
new
LinkedHashMap
<>();
private
static
final
Map
<
String
,
String
>
city
=
new
LinkedHashMap
<>();
/**
/**
* /store/Search?cid=1&page=1 POST请求
* /store/Search?cid=1&page=1 POST请求
...
@@ -46,10 +46,10 @@ public class FamilyMartCrawler {
...
@@ -46,10 +46,10 @@ public class FamilyMartCrawler {
String
html
=
elements
.
html
();
String
html
=
elements
.
html
();
Elements
options
=
Jsoup
.
parse
(
html
).
getElementsByTag
(
"option"
);
Elements
options
=
Jsoup
.
parse
(
html
).
getElementsByTag
(
"option"
);
for
(
Element
option
:
options
)
{
for
(
Element
option
:
options
)
{
city
s
.
put
(
option
.
text
(),
option
.
val
());
city
.
put
(
option
.
text
(),
option
.
val
());
}
}
city
s
.
forEach
((
cityName
,
cid
)
->
{
city
.
forEach
((
cityName
,
cid
)
->
{
String
station
=
HttpUtil
.
createPost
(
"http://www.familymart.com.cn/store/Search"
)
String
station
=
HttpUtil
.
createPost
(
"http://www.familymart.com.cn/store/Search"
)
.
form
(
"cid"
,
cid
)
.
form
(
"cid"
,
cid
)
.
form
(
"aid"
)
.
form
(
"aid"
)
...
@@ -61,8 +61,10 @@ public class FamilyMartCrawler {
...
@@ -61,8 +61,10 @@ public class FamilyMartCrawler {
.
execute
().
body
();
.
execute
().
body
();
List
<
Store
>
stores
=
new
JSONObject
(
station
).
getJSONArray
(
"mapmsg"
).
toList
(
Store
.
class
);
List
<
Store
>
stores
=
new
JSONObject
(
station
).
getJSONArray
(
"mapmsg"
).
toList
(
Store
.
class
);
stores
.
forEach
(
e
->
{
stores
.
forEach
(
e
->
{
CrawlerStore
crawlerStore
=
new
CrawlerStore
().
setCrawlerUrl
(
URL
)
CrawlerStore
crawlerStore
=
new
CrawlerStore
()
.
setSkName
(
SK_NAME
).
setPhone
(
e
.
getTelphone
())
.
setCrawlerUrl
(
URL
)
.
setSkName
(
SK_NAME
)
.
setPhone
(
e
.
getTelphone
())
.
setType
(
cityName
)
.
setType
(
cityName
)
.
setName
(
e
.
getName
())
.
setName
(
e
.
getName
())
.
setAddress
(
e
.
getStreet
())
.
setAddress
(
e
.
getStreet
())
...
...
src/main/java/com/deeprec/crawler/modules/seven_Eleven/crawler/SevenElevenCrawler.java
0 → 100644
View file @
7e3262e5
package
com
.
deeprec
.
crawler
.
modules
.
seven_Eleven
.
crawler
;
import
cn.hutool.http.HttpUtil
;
import
cn.hutool.json.JSONArray
;
import
cn.hutool.json.JSONObject
;
import
com.deeprec.crawler.entry.CrawlerStore
;
import
com.deeprec.crawler.mapper.InsertDB
;
import
com.deeprec.crawler.modules.seven_Eleven.dto.Store
;
import
lombok.extern.slf4j.Slf4j
;
import
java.util.ArrayList
;
import
java.util.List
;
@Slf4j
public
class
SevenElevenCrawler
{
private
static
final
String
SK_NAME
=
"7-11"
;
private
static
final
String
URL
=
"http://www.7-11cd.cn/shop/nearShop.aspx"
;
static
List
<
String
>
insertedList
=
new
ArrayList
<>();
public
static
void
main
(
String
[]
args
)
{
// 网站上目前只有成都的cityID
for
(
int
cityId
=
1000
;
cityId
<=
9999
;
cityId
++)
{
String
response
=
HttpUtil
.
createPost
(
"http://www.7-11cd.cn/AJAX/shop.ashx"
)
.
form
(
"action"
,
"getList"
)
.
form
(
"cityID"
,
cityId
)
.
execute
().
body
();
List
<
Store
>
stores
=
new
JSONArray
(
response
).
toList
(
Store
.
class
);
log
.
info
(
"查询到"
+
cityId
+
stores
);
if
(
stores
.
size
()
==
0
)
continue
;
for
(
Store
store
:
stores
)
{
if
(
insertedList
.
contains
(
store
.
getId
()))
continue
;
insertedList
.
add
(
store
.
getId
());
CrawlerStore
crawlerStore
=
new
CrawlerStore
().
setCrawlerUrl
(
URL
)
.
setSkName
(
SK_NAME
)
.
setPhone
(
store
.
getPhone
())
.
setName
(
store
.
getShopName
())
.
setAddress
(
store
.
getAddress
())
.
setExtInfo
(
new
JSONObject
()
.
set
(
"openDate"
,
store
.
getOpenDate
())
.
set
(
"cityFullName"
,
store
.
getCityFullName
()));
// InsertDB.getDB().insert(crawlerStore);
log
.
info
(
"区域: {},{}"
,
crawlerStore
.
getAddress
(),
crawlerStore
);
}
}
log
.
info
(
"7-11便利店全部插入完成"
);
}
}
src/main/java/com/deeprec/crawler/modules/seven_Eleven/dto/Store.java
0 → 100644
View file @
7e3262e5
package
com
.
deeprec
.
crawler
.
modules
.
seven_Eleven
.
dto
;
import
lombok.Data
;
@Data
public
class
Store
{
String
id
;
String
address
;
String
cityFullName
;
String
shopName
;
String
bMap_lat
;
String
bMap_lng
;
String
phone
;
String
openDate
;
}
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