Skip to content

Commit 28c2bf3

Browse files
committed
Issues checking improvements
1 parent cc02978 commit 28c2bf3

File tree

4 files changed

+20
-7
lines changed

4 files changed

+20
-7
lines changed

src/main/java/com/olegshan/parser/siteparsers/DouUaJobParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ public LocalDateTime getDate(Element job, String url, Elements titleBlock) throw
2626
String dateLine = dateDoc.getElementsByAttributeValue(
2727
jobSite.getDateData()[0],
2828
jobSite.getDateData()[1]).text();
29-
check(dateLine, "date line");
29+
check(dateLine, "date line", url);
3030
String[] dateParts = dateLine.split(jobSite.getSplit());
3131
MonthsTools.removeZero(dateParts);
3232

src/main/java/com/olegshan/parser/siteparsers/JobsUaJobParser.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public String getCompany(Element job, String url) throws ParserException {
3232
Elements companyBlock = jobDoc.getElementsByAttributeValue(companyData[0], companyData[1]);
3333

3434
String company = companyBlock.get(0).getElementsByTag("a").first().text();
35-
check(company, "company");
35+
check(company, "company", url);
3636
return company;
3737
}
3838
}

src/main/java/com/olegshan/parser/siteparsers/RabotaUaJobParser.java

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public Elements getJobBlocks(Document doc) throws ParserException {
3131
jobBlocks.addAll(jobElements);
3232
}
3333
}
34-
check(jobBlocks, "job blocks");
34+
check(jobBlocks, "job blocks", null);
3535
return jobBlocks;
3636
}
3737

@@ -44,6 +44,20 @@ public String getTitle(Elements titleBlock) {
4444
return title;
4545
}
4646

47+
@Override
48+
public String getCompany(Element job, String url) throws ParserException {
49+
String company = job.getElementsByAttributeValue(jobSite.getCompanyData()[0], jobSite.getCompanyData()[1]).text();
50+
if (company.length() == 0) {
51+
company = job.getElementsByAttributeValue("class", "s").text();
52+
if (company.startsWith("Анонимный работодатель")) {
53+
company = "Анонимный работодатель";
54+
} else {
55+
check(company, "company", url);
56+
}
57+
}
58+
return company;
59+
}
60+
4761
@Override
4862
public LocalDateTime getDate(Element job, String url, Elements titleBlock) throws ParserException {
4963
/*
@@ -78,7 +92,6 @@ public LocalDateTime getDate(Element job, String url, Elements titleBlock) throw
7892
year = Integer.parseInt(dateParts[2]);
7993
month = Integer.parseInt(dateParts[1]);
8094
day = Integer.parseInt(dateParts[0]);
81-
8295
} else {
8396
//for format yyyy-mm-dd
8497
dateParts = dateLine.split("-");

src/main/java/com/olegshan/parser/siteparsers/WorkUaJobParser.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public WorkUaJobParser(JobSite jobSite) {
2020
@Override
2121
public Elements getJobBlocks(Document doc) throws ParserException {
2222
Elements jobBlocks = doc.getElementsByAttributeValueStarting(jobSite.getJobBox()[0], jobSite.getJobBox()[1]);
23-
check(jobBlocks, "job blocks");
23+
check(jobBlocks, "job blocks", null);
2424
return jobBlocks;
2525
}
2626

@@ -33,7 +33,7 @@ public Elements getTitleBlock(Element job) {
3333
public LocalDateTime getDate(Element job, String url, Elements titleBlock) throws ParserException {
3434
String dateLine = titleBlock.attr("title");
3535
String[] dateParts = dateLine.substring(dateLine.length() - 8).split(jobSite.getSplit());
36-
check(dateParts, "date parts");
36+
check(dateParts, "date parts", url);
3737

3838
int year = parseInt(dateParts[2]) + 2000;
3939
int month = parseInt(dateParts[1]);
@@ -47,7 +47,7 @@ public String getCompany(Element job, String url) throws ParserException {
4747
String[] companyData = jobSite.getCompanyData();
4848
Document jobDoc = getDoc(url);
4949
Elements companyBlock = jobDoc.getElementsByAttributeValue(companyData[0], companyData[1]);
50-
check(companyBlock, "company block");
50+
check(companyBlock, "company block", url);
5151
return companyBlock.get(0).getElementsByTag("a").text();
5252
}
5353
}

0 commit comments

Comments
 (0)