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
6a828e92
Commit
6a828e92
authored
Dec 03, 2013
by
yihua.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
#46 Downloader thread hang up when timeout
parent
486d9d27
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
5 additions
and
2 deletions
+5
-2
user-manual.md
user-manual.md
+2
-2
HttpClientDownloader.java
...s/codecraft/webmagic/downloader/HttpClientDownloader.java
+1
-0
ScriptConsole.java
...ain/java/us/codecraft/webmagic/scripts/ScriptConsole.java
+1
-0
ScriptEnginePool.java
.../java/us/codecraft/webmagic/scripts/ScriptEnginePool.java
+1
-0
No files found.
user-manual.md
View file @
6a828e92
...
...
@@ -27,12 +27,12 @@ webmagic使用maven管理依赖,在项目中添加对应的依赖即可使用w
<dependency>
<groupId>us.codecraft</groupId>
<artifactId>webmagic-core</artifactId>
<version>0.4.
0
</version>
<version>0.4.
1
</version>
</dependency>
<dependency>
<groupId>us.codecraft</groupId>
<artifactId>webmagic-extension</artifactId>
<version>0.4.
0
</version>
<version>0.4.
1
</version>
</dependency>
#### 项目结构
...
...
webmagic-core/src/main/java/us/codecraft/webmagic/downloader/HttpClientDownloader.java
View file @
6a828e92
...
...
@@ -105,6 +105,7 @@ public class HttpClientDownloader implements Downloader {
}
RequestConfig
.
Builder
requestConfigBuilder
=
RequestConfig
.
custom
()
.
setConnectionRequestTimeout
(
site
.
getTimeOut
())
.
setSocketTimeout
(
site
.
getTimeOut
())
.
setConnectTimeout
(
site
.
getTimeOut
())
.
setCookieSpec
(
CookieSpecs
.
BEST_MATCH
);
if
(
site
!=
null
&&
site
.
getHttpProxy
()
!=
null
)
{
...
...
webmagic-scripts/src/main/java/us/codecraft/webmagic/scripts/ScriptConsole.java
View file @
6a828e92
...
...
@@ -93,6 +93,7 @@ public class ScriptConsole {
.
language
(
params
.
getLanguage
()).
scriptFromFile
(
params
.
getScriptFileName
()).
thread
(
params
.
getThread
()).
build
();
pageProcessor
.
getSite
().
setSleepTime
(
params
.
getSleepTime
());
pageProcessor
.
getSite
().
setAcceptStatCode
(
Sets
.<
Integer
>
newHashSet
(
200
,
404
,
500
));
pageProcessor
.
getSite
().
setUserAgent
(
"Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_8; en-US) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.0.249.0 Safari/532.5"
);
Spider
spider
=
Spider
.
create
(
pageProcessor
).
thread
(
params
.
getThread
());
spider
.
clearPipeline
().
addPipeline
(
new
Pipeline
()
{
@Override
...
...
webmagic-scripts/src/main/java/us/codecraft/webmagic/scripts/ScriptEnginePool.java
View file @
6a828e92
...
...
@@ -34,6 +34,7 @@ public class ScriptEnginePool {
public
void
release
(
ScriptEngine
scriptEngine
){
scriptEngines
.
add
(
scriptEngine
);
availableCount
.
incrementAndGet
();
}
}
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