File tree Expand file tree Collapse file tree 3 files changed +15
-1
lines changed
webmagic-core/src/main/java/us/codecraft/webmagic/selector Expand file tree Collapse file tree 3 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,11 @@ public Selectable smartContent() {
31
31
return select (smartContentSelector , getSourceTexts ());
32
32
}
33
33
34
+ public Selectable smartContent (int threshold ) {
35
+ SmartContentSelector smartContentSelector = Selectors .smartContent (threshold );
36
+ return select (smartContentSelector , getSourceTexts ());
37
+ }
38
+
34
39
@ Override
35
40
public Selectable links () {
36
41
return selectElements (new LinksSelector ());
Original file line number Diff line number Diff line change @@ -20,6 +20,10 @@ public static SmartContentSelector smartContent() {
20
20
return new SmartContentSelector ();
21
21
}
22
22
23
+ public static SmartContentSelector smartContent (int threshold ) {
24
+ return new SmartContentSelector (threshold );
25
+ }
26
+
23
27
public static CssSelector $ (String expr ) {
24
28
return new CssSelector (expr );
25
29
}
Original file line number Diff line number Diff line change 16
16
@ Experimental
17
17
public class SmartContentSelector implements Selector {
18
18
19
+ private int threshold = 86 ;
20
+
19
21
public SmartContentSelector () {
20
22
}
21
23
24
+ public SmartContentSelector (int threshold ) {
25
+ this .threshold = threshold ;
26
+ }
27
+
22
28
@ Override
23
29
public String select (String html ) {
24
30
html = html .replaceAll ("(?is)<!DOCTYPE.*?>" , "" );
@@ -29,7 +35,6 @@ public String select(String html) {
29
35
html = html .replaceAll ("(?is)<.*?>" , "" );
30
36
List <String > lines ;
31
37
int blocksWidth =3 ;
32
- int threshold =86 ;
33
38
int start ;
34
39
int end ;
35
40
StringBuilder text = new StringBuilder ();
You can’t perform that action at this time.
0 commit comments