Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
修改SmartContentSelector threshold可定制化
  • Loading branch information
zhaoyiwei committed Dec 11, 2024
commit 697d9d2b1b1b406d2f73a0bdd2f4cc2f67a86c0c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ public static SmartContentSelector smartContent() {
return new SmartContentSelector();
}

public static SmartContentSelector smartContent(int threshold) {
return new SmartContentSelector(threshold);
}

public static CssSelector $(String expr) {
return new CssSelector(expr);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,15 @@
@Experimental
public class SmartContentSelector implements Selector {

private int threshold = 86;

public SmartContentSelector() {
}

public SmartContentSelector(int threshold) {
this.threshold = threshold;
}

@Override
public String select(String html) {
html = html.replaceAll("(?is)<!DOCTYPE.*?>", "");
Expand All @@ -29,7 +35,6 @@ public String select(String html) {
html = html.replaceAll("(?is)<.*?>", "");
List<String> lines;
int blocksWidth =3;
int threshold =86;
int start;
int end;
StringBuilder text = new StringBuilder();
Expand Down