Skip to content
This repository has been archived by the owner on Jan 19, 2022. It is now read-only.

Commit

Permalink
Version 2.1.7
Browse files Browse the repository at this point in the history
1. Ещё немного почистили текст.
2. Исправили редкий баг, когда первый абзац не сохранялся.
  • Loading branch information
megoRU committed Nov 13, 2020
1 parent c0b18f3 commit f4115b9
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 29 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>ficbook.net_Parser</groupId>
<artifactId>ficbook.net_Parser</artifactId>
<version>2.1.0-SNAPSHOT</version>
<version>2.1.7-SNAPSHOT</version>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
53 changes: 25 additions & 28 deletions src/main/java/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -194,33 +194,34 @@ public void parsing(String textFromJText) {
is = url.openStream();
brs = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
FileWriter writerFile = new FileWriter(pathForHTML, StandardCharsets.UTF_8);

//Сохраняем просто в файл site.html
//форматируем текст
while ((lines = brs.readLine()) != null) {
writerFile.write(lines
.replaceAll("&nbsp;", "")
.trim()
.replaceAll("</b>", "")
.replaceAll("</div>", "")
.replaceAll("</i>", "")
.replaceAll("<i>", "")
.replaceAll("<p align=\"center\" style=\"margin: 0;\">", "")
.replaceAll("</p>", "")
.replaceAll("<div class=\"part-comment-bottom mx-10 mx-xs-5\">", "")
.replaceAll("<strong>", "")
.replaceAll("</strong>", "")
.replaceAll("<div class=\"urlize\">", "")
.replaceAll("<br />", "")
.replaceAll("<p align=\"right\" style=\"margin: 0;\"><b>", "")
.replaceAll("<p align=\"right\" style=\"margin: 0;\">", "")
+ System.getProperty("line.separator"));
writerFile.write(lines
.replaceAll("&nbsp;", "")
.trim()
.replaceAll("</b>", "")
.replaceAll("</div>", "")
.replaceAll("</i>", "")
.replaceAll("<i>", "")
.replaceAll("<p align=\"center\" style=\"margin: 0;\">", "")
.replaceAll("</p>", "")
.replaceAll("<div class=\"part-comment-bottom mx-10 mx-xs-5\">", "")
.replaceAll("<strong>", "")
.replaceAll("</strong>", "")
.replaceAll("<div class=\"urlize\">", "")
.replaceAll("<br />", "")
.replaceAll("<p align=\"right\" style=\"margin: 0;\"><b>", "")
.replaceAll("<p align=\"right\" style=\"margin: 0;\">", "")
.replaceAll("</s>", "")
.replaceAll("<s>", "")

+ System.getProperty("line.separator"));
}

is.close();
brs.close();
writerFile.close();

//Путь для сохранения почти готового результата
String pathBeforeSave = "C:/Users/" + userName + "/Desktop/" + textTitle + "NOT_FINAL" + ".txt";

Expand Down Expand Up @@ -267,21 +268,18 @@ public static void delete(String filePathIn, String filePathOut, int toRemove) {
while ((currentLine = reader.readLine()) != null) {
count++;
if (count < toRemove) {

continue;
}
if (count > toRemove) {
if (first < 1) {
first++;
int length = currentLine.length();
int symbol = currentLine.lastIndexOf(">") + 1;
String firstLine = currentLine.substring(symbol, length);
String firstLine = currentLine.replaceAll("data-is-adult=\"1\" itemprop=\"articleBody\">", "");
bufferWriter.write(firstLine + System.getProperty("line.separator"));
continue;
bufferWriter.write(System.getProperty("line.separator"));
}
if (first > 1) {
bufferWriter.write(currentLine.trim() + System.getProperty("line.separator"));
}
bufferWriter.write(currentLine.trim() + System.getProperty("line.separator"));
first++;
}
}
bufferWriter.close();
Expand All @@ -306,7 +304,6 @@ public static void deleteSecond(String filePathIn, String filePathOut, int toRem
if (count > toRemove) {
}
if (count <= toRemove) {
//linesBook.add(currentLine.trim() + System.getProperty("line.separator"));
bufferWriter.write(currentLine.trim() + System.getProperty("line.separator"));
}
}
Expand Down Expand Up @@ -345,7 +342,7 @@ public static int linesSecond(String filePathIn) {
lineCount++;
}
reader.close();
return lineCount - 2;
return lineCount - 2; //Зачем. Но лучше не трогать.
} catch (Exception e) {
e.printStackTrace();
}
Expand Down

0 comments on commit f4115b9

Please sign in to comment.