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
787b9529
Commit
787b9529
authored
Aug 11, 2013
by
yihua.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
release notes and docs
parent
1f86ce77
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
5 deletions
+31
-5
release-note.md
release-note.md
+3
-1
Spider.java
...agic-core/src/main/java/us/codecraft/webmagic/Spider.java
+10
-2
GithubRepo.java
.../java/us/codecraft/webmagic/model/samples/GithubRepo.java
+18
-2
No files found.
release-note.md
View file @
787b9529
...
@@ -28,13 +28,15 @@ Release Notes
...
@@ -28,13 +28,15 @@ Release Notes
}
}
增加一个Spider.test(url)方法,用于开发爬虫时进行调试。
增加基于redis的分布式支持。
增加基于redis的分布式支持。
增加XPath2.0语法支持(webmagic-saxon模块)。
增加XPath2.0语法支持(webmagic-saxon模块)。
增加基于Selenium的浏览器渲染支持,用于抓取动态加载内容(webmagic-selenium模块)。
增加基于Selenium的浏览器渲染支持,用于抓取动态加载内容(webmagic-selenium模块)。
修复
一些已有
bug。
修复
了不支持https的
bug。
补充了文档:
[
webmagic-0.2.0用户手册
](
http://code4craft.github.io/webmagic/
)
。
补充了文档:
[
webmagic-0.2.0用户手册
](
http://code4craft.github.io/webmagic/
)
。
...
...
webmagic-core/src/main/java/us/codecraft/webmagic/Spider.java
View file @
787b9529
...
@@ -220,10 +220,18 @@ public class Spider implements Runnable, Task {
...
@@ -220,10 +220,18 @@ public class Spider implements Runnable, Task {
}
}
}
}
public
void
test
(
String
url
){
/**
* 用某些特定URL进行爬虫测试
* @param urls 要抓取的url
*/
public
void
test
(
String
...
urls
){
checkComponent
();
checkComponent
();
if
(
urls
.
length
>
0
){
for
(
String
url
:
urls
)
{
processRequest
(
new
Request
(
url
));
processRequest
(
new
Request
(
url
));
}
}
}
}
private
void
processRequest
(
Request
request
)
{
private
void
processRequest
(
Request
request
)
{
Page
page
=
downloader
.
download
(
request
,
this
);
Page
page
=
downloader
.
download
(
request
,
this
);
...
...
webmagic-samples/src/main/java/us/codecraft/webmagic/model/samples/GithubRepo.java
View file @
787b9529
...
@@ -8,6 +8,7 @@ import us.codecraft.webmagic.model.annotation.ExtractByUrl;
...
@@ -8,6 +8,7 @@ import us.codecraft.webmagic.model.annotation.ExtractByUrl;
import
us.codecraft.webmagic.model.annotation.HelpUrl
;
import
us.codecraft.webmagic.model.annotation.HelpUrl
;
import
us.codecraft.webmagic.model.annotation.TargetUrl
;
import
us.codecraft.webmagic.model.annotation.TargetUrl
;
import
us.codecraft.webmagic.pipeline.JsonFilePageModelPipeline
;
import
us.codecraft.webmagic.pipeline.JsonFilePageModelPipeline
;
import
us.codecraft.webmagic.scheduler.FileCacheQueueScheduler
;
import
java.util.List
;
import
java.util.List
;
...
@@ -32,12 +33,19 @@ public class GithubRepo implements HasKey {
...
@@ -32,12 +33,19 @@ public class GithubRepo implements HasKey {
@ExtractBy
(
value
=
"//div[@class='repository-lang-stats']//li//span[@class='lang']"
,
multi
=
true
)
@ExtractBy
(
value
=
"//div[@class='repository-lang-stats']//li//span[@class='lang']"
,
multi
=
true
)
private
List
<
String
>
language
;
private
List
<
String
>
language
;
@ExtractBy
(
"//a[@class='social-count js-social-count']/text()"
)
private
String
star
;
@ExtractBy
(
"//a[@class='social-count js-social-count']/text()"
)
private
String
fork
;
@ExtractByUrl
@ExtractByUrl
private
String
url
;
private
String
url
;
public
static
void
main
(
String
[]
args
)
{
public
static
void
main
(
String
[]
args
)
{
OOSpider
.
create
(
Site
.
me
().
addStartUrl
(
"https://github.com/explore"
).
setSleepTime
(
0
),
OOSpider
.
create
(
Site
.
me
().
addStartUrl
(
"https://github.com/explore"
).
setSleepTime
(
0
).
setRetryTimes
(
3
),
new
JsonFilePageModelPipeline
(),
GithubRepo
.
class
).
thread
(
15
).
run
();
new
JsonFilePageModelPipeline
(),
GithubRepo
.
class
)
.
scheduler
(
new
FileCacheQueueScheduler
(
"/data/webmagic/cache/"
)).
thread
(
15
).
run
();
}
}
@Override
@Override
...
@@ -64,4 +72,12 @@ public class GithubRepo implements HasKey {
...
@@ -64,4 +72,12 @@ public class GithubRepo implements HasKey {
public
String
getUrl
()
{
public
String
getUrl
()
{
return
url
;
return
url
;
}
}
public
String
getStar
()
{
return
star
;
}
public
String
getFork
()
{
return
fork
;
}
}
}
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