Exemplo n.º 1
0
  public void xinqiang1() throws FileNotFoundException {

    ScraperConfiguration config = new ScraperConfiguration("src/xinqiang/xinqiang1.xml");
    Scraper scraper = new Scraper(config, "d:/wh/work/");
    scraper.setDebug(true);
    scraper.execute();
    Variable r1 = scraper.getContext().getVar("targetPage");
    System.out.println(r1.toString());
  }
Exemplo n.º 2
0
  public String chongqing2() throws FileNotFoundException {
    ScraperConfiguration config = new ScraperConfiguration("src/chongqing/chongqing2.xml");
    Scraper scraper = new Scraper(config, "d:/wh/work/");
    scraper.setDebug(true);
    scraper.execute();
    //		Variable r1 = scraper.getContext().getVar("targetPage");
    //		System.out.println(r1.toString());
    //		System.out.println("----------------");
    Variable catalog = scraper.getContext().getVar("catalog");
    //		System.out.println(catalog);
    //		System.out.println("===========");
    String s = catalog.toString().replaceAll("<result>", ",{").replaceAll("</result>", "}");
    System.out.println("[" + s.substring(1) + "]");
    return "[" + s.substring(1) + "]";
    //		System.out.println(catalog.toList());
    //		List list = catalog.toList();
    //		for (Object s :list) {
    //			Map<String,Object> m = (Map<String, Object>) s;
    //			System.out.println("-->"+m.get("qs"));
    //		}

    //		Variable result = scraper.getContext().getVar("result");
    //		System.out.println(result);
  }