View Javadoc
1   package us.codecraft.webmagic.selector;
2   
3   /**
4    * Convenient methods for selectors.<br>
5    *
6    * @author code4crafter@gmail.com <br>
7    * @since 0.2.1
8    */
9   public abstract class Selectors {
10  
11      public static RegexSelector regex(String expr) {
12          return new RegexSelector(expr);
13      }
14  
15      public static RegexSelector regex(String expr, int group) {
16          return new RegexSelector(expr,group);
17      }
18  
19      public static SmartContentSelector smartContent() {
20          return new SmartContentSelector();
21      }
22  
23      public static CssSelector $(String expr) {
24          return new CssSelector(expr);
25      }
26  
27      public static CssSelector $(String expr, String attrName) {
28          return new CssSelector(expr, attrName);
29      }
30  
31      public static XpathSelector xpath(String expr) {
32          return new XpathSelector(expr);
33      }
34  
35      /**
36       * @see #xpath(String)
37       * @param expr expr
38       * @return new selector
39       */
40      @Deprecated
41      public static XpathSelector xsoup(String expr) {
42          return new XpathSelector(expr);
43      }
44  
45      public static AndSelector and(Selector... selectors) {
46          return new AndSelector(selectors);
47      }
48  
49      public static OrSelector or(Selector... selectors) {
50          return new OrSelector(selectors);
51      }
52  
53  }