Do not cache document in Selectable for selected Html element #73
parent
6201fd6966
commit
8b35d79569
@ -1,20 +0,0 @@
|
||||
package us.codecraft.webmagic.avalon.web;
|
||||
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
/**
|
||||
* @author code4crafter@gmail.com
|
||||
*/
|
||||
@Controller("dashboard")
|
||||
@RequestMapping("/")
|
||||
public class DashBoardController {
|
||||
|
||||
@RequestMapping
|
||||
public ModelAndView index() {
|
||||
ModelAndView map = new ModelAndView("dashboard");
|
||||
return map;
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package us.codecraft.webmagic.selector;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* @author code4crafter@gmail.com
|
||||
*/
|
||||
public class SelectorTest {
|
||||
|
||||
private String html = "<div><a href='http://whatever.com/aaa'></a></div><div><a href='http://whatever.com/bbb'></a></div>";
|
||||
|
||||
@Test
|
||||
public void testChain() throws Exception {
|
||||
Html selectable = new Html(html);
|
||||
List<String> linksWithoutChain = selectable.links().all();
|
||||
Selectable xpath = selectable.xpath("//div");
|
||||
List<String> linksWithChainFirstCall = xpath.links().all();
|
||||
List<String> linksWithChainSecondCall = xpath.links().all();
|
||||
assertThat(linksWithoutChain).hasSameSizeAs(linksWithChainFirstCall);
|
||||
assertThat(linksWithChainFirstCall).hasSameSizeAs(linksWithChainSecondCall);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue