Skip to content
Permalink
Browse files

Updated ListingParser, closes #1

  • Loading branch information...
sitfoxfly committed Mar 21, 2019
1 parent 30044fe commit b29334ee78e7ba0566a6e61c1f3c5cbc39e63db9
Showing with 15 additions and 23 deletions.
  1. +3 −10 pom.xml
  2. +12 −13 src/main/java/ai/preferred/crawler/iproperty/master/ListingParser.java
13 pom.xml
@@ -6,23 +6,16 @@

<groupId>ai.preferred</groupId>
<artifactId>venom-examples</artifactId>
<version>1.0</version>
<version>1.0.1</version>

<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.6.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
@@ -18,8 +18,8 @@ private ListingParser() {
throw new UnsupportedOperationException();
}

public static List<Property> parseListing(Document document) {
final Elements properties = document.select("ul.listing-list.dZUSMd > li[class~=rent]");
static List<Property> parseListing(Document document) {
final Elements properties = document.select("ul.listing-list > li[class~=rent]");
final ArrayList<Property> result = new ArrayList<>(properties.size());
for (final Element p : properties) {
result.add(parseProperty(p));
@@ -47,8 +47,8 @@ private static Property parseProperty(Element e) {
final Property property = new Property();

property.setPrice(textOrNull(e.select("li[class~=listing-primary-price-item]").first()));
property.setArea(textOrNull(e.select("li.attributes-price-per-unit-size-item.fsbnan > a").first()));
property.setPsf(textOrNull(e.select("p[class~=secondary-price ]").first()));
property.setArea(textOrNull(e.select("li.attributes-price-per-unit-size-item > a").first()));
property.setPsf(textOrNull(e.select("p.secondary-price").first()));

for (final Element facility : e.select("li.attributes-facilities-item-wrapper")) {
if (facility.hasClass("bedroom-facility")) {
@@ -62,17 +62,16 @@ private static Property parseProperty(Element e) {
}
}

if (e.select("div.gPrykj").isEmpty()) {
if (e.select("h3 > a[href~=/rent]").isEmpty()) {
property.setUrl(e.selectFirst("h3 > p > a[href]").attr("abs:href"));
property.setAddress(e.select("div.sc-iclvYL > div > a").text());
property.setType(e.select("div.sc-OJyzl > div > a").text());
property.setTitle(e.select("h3 > p > a[href]").text());
} else {
property.setUrl(e.select("p.row-one-left-col-listing-location > a").attr("abs:href"));
property.setAddress(e.select("p.row-one-left-col-listing-location").text());
property.setTitle(e.select("h3.cgiArp").text());
property.setUrl(e.select("h3.cgiArp > a").attr("abs:href"));
property.setType(e.select("p.property-type-content").text());
} else {
property.setAddress(e.select("div.fsKEtj > a").text());
property.setTitle(e.select("p.jPjrzv").text());
property.setUrl(e.select("p.jPjrzv > a").attr("abs:href"));
property.setType(e.select("div.eqkyrG").text());
property.setPsf(textOrNull(e.select("div.boastAt > p > a").first()));
property.setTitle(e.select("h3 > a[href~=/rent]").text());
}

return property;

0 comments on commit b29334e

Please sign in to comment.
You can’t perform that action at this time.