Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
W
webmagic
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
沈俊林
webmagic
Commits
902256d8
Commit
902256d8
authored
Dec 18, 2016
by
yihua.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
readme
parent
5cce68ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
51 additions
and
5 deletions
+51
-5
index.md
index.md
+51
-5
No files found.
index.md
View file @
902256d8
...
...
@@ -11,21 +11,67 @@ WebMagic是一个简单灵活的爬虫框架。基于WebMagic,你可以快速
*
模块化的结构,可轻松扩展
*
提供多线程和分布式支持
一个示例:
```
java
public
class
GithubRepoPageProcessor
implements
PageProcessor
{
private
Site
site
=
Site
.
me
().
setRetryTimes
(
3
).
setSleepTime
(
1000
).
setTimeOut
(
10000
);
@Override
public
void
process
(
Page
page
)
{
page
.
addTargetRequests
(
page
.
getHtml
().
links
().
regex
(
"(https://github\\.com/[\\w\\-]+/[\\w\\-]+)"
).
all
());
page
.
addTargetRequests
(
page
.
getHtml
().
links
().
regex
(
"(https://github\\.com/[\\w\\-])"
).
all
());
page
.
putField
(
"author"
,
page
.
getUrl
().
regex
(
"https://github\\.com/(\\w+)/.*"
).
toString
());
page
.
putField
(
"name"
,
page
.
getHtml
().
xpath
(
"//h1[@class='entry-title public']/strong/a/text()"
).
toString
());
if
(
page
.
getResultItems
().
get
(
"name"
)==
null
){
//skip this page
page
.
setSkip
(
true
);
}
page
.
putField
(
"readme"
,
page
.
getHtml
().
xpath
(
"//div[@id='readme']/tidyText()"
));
}
@Override
public
Site
getSite
()
{
return
site
;
}
public
static
void
main
(
String
[]
args
)
{
Spider
.
create
(
new
GithubRepoPageProcessor
()).
addUrl
(
"https://github.com/code4craft"
).
thread
(
5
).
run
();
}
}
```
## 下载:
添加Maven依赖:
```
xml
<dependency>
<groupId>
us.codecraft
</groupId>
<artifactId>
webmagic-core
</artifactId>
<version>
0.6.0
</version>
</dependency>
<dependency>
<groupId>
us.codecraft
</groupId>
<artifactId>
webmagic-extension
</artifactId>
<version>
0.6.0
</version>
</dependency>
```
## 文档:
*
中文:
http://webmagic.io/docs/zh/
*
English:
http://webmagic.io/docs/en
*
中文:
[
http://webmagic.io/docs/zh/
](
http://webmagic.io/docs/zh/
)
*
English:
[
http://webmagic.io/docs/en
](
http://webmagic.io/docs/en
)
## 源码:
*
https://git.oschina.net/flashsword20/webmagic
*
https://github.com/code4craft/webmagic
*
[
https://git.oschina.net/flashsword20/webmagic
](
https://git.oschina.net/flashsword20/webmagic
)
*
[
https://github.com/code4craft/webmagic
](
https://github.com/code4craft/webmagic
)
## 讨论:
*
bug反馈及建议:
https://github.com/code4craft/webmagic/issues
*
bug反馈及建议:
[
https://github.com/code4craft/webmagic/issues
](
https://github.com/code4craft/webmagic/issues
)
*
qq群:373225642
## 支持我们
...
...
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