ng getUrl() {
return url;
}
public void setUrl(String url) {
this.url = url;
}
}
/***********************************************************/
package cn.rssweb.site.web;
import java.io.DataOutputStream;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import cn.rssweb.edp.component.spider.RobotFactory;
import cn.rssweb.edp.component.spider.model.DataModel;
import cn.rssweb.edp.component.spider.robot.Robot;
public class NewsListServlet extends HttpServlet {
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String url = "http://www.techweb.com.cn/news/20.shtml";
Robot robot = RobotFactory.getInstance(Robot.HTML,url);//服务器逻辑处理核心类,此略
List list = robot.parseList();
Iterator it = list.iterator();
int i=0;
StringBuffer sb = new StringBuffer();
while(it.hasNext()){
i++;
DataModel data = (DataModel)it.next();
String title = data.getLinkText();
sb.append(i).append(".").append(title).append("n");
}
DataOutputStream dos = new DataOutputStream(response.getOutputStream());
dos.writeUTF(sb.toString());
dos.flush();
dos.close();
}
@Override
protected void doPost(HttpServletRequest arg0, HttpServletResponse arg1)
throws ServletException, IOException {
super.doPost(arg0, arg1);
}
}
/***********************************************************/
|