Commit 4cd3e1d8 authored by yihua.huang's avatar yihua.huang

add build script

parent 81bb809d
#!/bin/sh
VERSION="0.4.1-SNAPTHOS"
mvn clean package
cp target/webmagic-scripts-${VERSION}.jar /usr/local/webmagic/webmagic-console.jar
rsync -avz --delete target/lib/ /usr/local/webmagic/lib/
...@@ -105,6 +105,7 @@ public class ScriptConsole { ...@@ -105,6 +105,7 @@ public class ScriptConsole {
options.addOption(new Option("l", true, "language")); options.addOption(new Option("l", true, "language"));
options.addOption(new Option("t", true, "thread")); options.addOption(new Option("t", true, "thread"));
options.addOption(new Option("f", true, "script file")); options.addOption(new Option("f", true, "script file"));
options.addOption(new Option("s", true, "sleep time"));
CommandLineParser commandLineParser = new PosixParser(); CommandLineParser commandLineParser = new PosixParser();
CommandLine commandLine = commandLineParser.parse(options, args); CommandLine commandLine = commandLineParser.parse(options, args);
return readOptions(commandLine); return readOptions(commandLine);
......
...@@ -50,7 +50,7 @@ public class ScriptProcessor implements PageProcessor { ...@@ -50,7 +50,7 @@ public class ScriptProcessor implements PageProcessor {
context.setAttribute("page", page, ScriptContext.ENGINE_SCOPE); context.setAttribute("page", page, ScriptContext.ENGINE_SCOPE);
context.setAttribute("config", site, ScriptContext.ENGINE_SCOPE); context.setAttribute("config", site, ScriptContext.ENGINE_SCOPE);
try { try {
engine.eval(defines + script, context); engine.eval(defines + "\n" + script, context);
} catch (ScriptException e) { } catch (ScriptException e) {
e.printStackTrace(); e.printStackTrace();
} }
......
...@@ -7,4 +7,4 @@ function xpath(str){ ...@@ -7,4 +7,4 @@ function xpath(str){
function urls(str){ function urls(str){
links = page.getHtml().links().regex(str).all(); links = page.getHtml().links().regex(str).all();
page.addTargetRequests(links); page.addTargetRequests(links);
} }
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment