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
48fd0033
Commit
48fd0033
authored
Aug 07, 2013
by
yihua.huang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
remove freemarker dep
parent
521fbad9
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
0 additions
and
62 deletions
+0
-62
pom.xml
webmagic-samples/pom.xml
+0
-5
FreemarkerPipeline.java
...va/us/codecraft/webmagic/pipeline/FreemarkerPipeline.java
+0
-57
No files found.
webmagic-samples/pom.xml
View file @
48fd0033
...
...
@@ -22,11 +22,6 @@
<artifactId>
webmagic-extension
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
org.freemarker
</groupId>
<artifactId>
freemarker
</artifactId>
<version>
2.3.15
</version>
</dependency>
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
...
...
webmagic-samples/src/main/java/us/codecraft/webmagic/pipeline/FreemarkerPipeline.java
deleted
100644 → 0
View file @
521fbad9
package
us
.
codecraft
.
webmagic
.
pipeline
;
import
freemarker.template.Configuration
;
import
freemarker.template.Template
;
import
freemarker.template.TemplateException
;
import
org.apache.commons.codec.digest.DigestUtils
;
import
us.codecraft.webmagic.ResultItems
;
import
us.codecraft.webmagic.Task
;
import
java.io.File
;
import
java.io.FileWriter
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
/**
* @author code4crafter@gmail.com <br>
* Date: 13-6-8
* Time: 下午9:00
*/
public
class
FreemarkerPipeline
implements
Pipeline
{
private
Configuration
configuration
;
private
Template
template
;
private
String
path
=
"/data/temp/webmagic/ftl/"
;
public
FreemarkerPipeline
(
String
template
,
String
path
)
throws
IOException
{
configuration
=
new
Configuration
();
configuration
.
setDirectoryForTemplateLoading
(
new
File
(
this
.
getClass
().
getClassLoader
().
getResource
(
"ftl/"
).
getFile
()));
this
.
template
=
configuration
.
getTemplate
(
template
);
this
.
path
=
path
;
new
File
(
path
);
}
public
FreemarkerPipeline
(
String
template
)
throws
IOException
{
this
(
template
,
"/data/temp/webmagic/ftl/"
);
}
@Override
public
void
process
(
ResultItems
resultItems
,
Task
task
)
{
String
path
=
this
.
path
+
""
+
task
.
getUUID
()
+
"/"
;
File
file
=
new
File
(
path
);
if
(!
file
.
exists
())
{
file
.
mkdirs
();
}
try
{
PrintWriter
printWriter
=
new
PrintWriter
(
new
FileWriter
(
path
+
DigestUtils
.
md5Hex
(
resultItems
.
getRequest
().
getUrl
())
+
".html"
));
template
.
process
(
resultItems
.
getAll
(),
printWriter
);
printWriter
.
close
();
}
catch
(
TemplateException
e
)
{
}
catch
(
IOException
e
)
{
e
.
printStackTrace
();
}
}
}
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