mirror of https://github.com/bvn13/imdb-spider.git
start working on project
parent
583f622aa7
commit
4205b7ad27
|
@ -21,3 +21,8 @@
|
||||||
|
|
||||||
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
|
||||||
hs_err_pid*
|
hs_err_pid*
|
||||||
|
|
||||||
|
#intellij
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
*.iml
|
||||||
|
|
|
@ -0,0 +1,43 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<groupId>ru.bvn13.imdbspider</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>imdb-spider-core</artifactId>
|
||||||
|
|
||||||
|
<name>IMDB-SPIDER :: CORE</name>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<!--<dependency>-->
|
||||||
|
<!--<groupId>org.jdom</groupId>-->
|
||||||
|
<!--<artifactId>jdom2</artifactId>-->
|
||||||
|
<!--<version>2.0.6</version>-->
|
||||||
|
<!--</dependency>-->
|
||||||
|
<!--<dependency>-->
|
||||||
|
<!--<groupId>jaxen</groupId>-->
|
||||||
|
<!--<artifactId>jaxen</artifactId>-->
|
||||||
|
<!--<version>1.1.6</version>-->
|
||||||
|
<!--</dependency>-->
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,9 @@
|
||||||
|
module imdb.spider.core {
|
||||||
|
//exports ru.bvn13.imdbspider;
|
||||||
|
exports ru.bvn13.imdbspider.imdb;
|
||||||
|
exports ru.bvn13.imdbspider.spider.tasker;
|
||||||
|
exports ru.bvn13.imdbspider.exceptions;
|
||||||
|
|
||||||
|
requires java.xml;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,78 @@
|
||||||
|
package ru.bvn13.imdbspider;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.api.DataTypeNotSupportedException;
|
||||||
|
import ru.bvn13.imdbspider.imdb.Movie;
|
||||||
|
import ru.bvn13.imdbspider.imdb.MovieDataType;
|
||||||
|
import ru.bvn13.imdbspider.spider.api.v1_0.ApiFactory_1_0;
|
||||||
|
import ru.bvn13.imdbspider.spider.tasker.Manager;
|
||||||
|
import ru.bvn13.imdbspider.spider.tasker.Task;
|
||||||
|
import ru.bvn13.imdbspider.spider.api.ApiFactory;
|
||||||
|
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.nio.charset.Charset;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.EnumSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.ExecutionException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class ImdbSpider {
|
||||||
|
|
||||||
|
private static final String URL_MAIN = "https://www.imdb.com/";
|
||||||
|
private static final String URL_SEARCH_TITLE = "https://www.imdb.com/find?ref_=nv_sr_fn&q={{title}}&s=tt";
|
||||||
|
|
||||||
|
private Manager manager;
|
||||||
|
|
||||||
|
private ApiFactory apiFactory;
|
||||||
|
|
||||||
|
public static ImdbSpider withApi_1_0() {
|
||||||
|
return new ImdbSpider(new ApiFactory_1_0());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public ImdbSpider(ApiFactory apiFactory) {
|
||||||
|
|
||||||
|
manager = new Manager();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Movie> searchMovieByTitle(String title) {
|
||||||
|
return searchMovieByTitle(title, 10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Movie> searchMovieByTitle(String title, int maxCount) {
|
||||||
|
return searchMovieByTitle(title, maxCount, EnumSet.of(MovieDataType.TITLE));
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Movie> searchMovieByTitle(String title, int maxCount, EnumSet<MovieDataType> dataTypes) {
|
||||||
|
|
||||||
|
String url = URL_SEARCH_TITLE.replace("{{title}}", URLEncoder.encode(title, Charset.forName("utf-8")));
|
||||||
|
|
||||||
|
List<Task> tasks = new ArrayList<>();
|
||||||
|
|
||||||
|
for (MovieDataType mdt : MovieDataType.values()) {
|
||||||
|
if (dataTypes.contains(mdt)) {
|
||||||
|
try {
|
||||||
|
tasks.add(apiFactory.taskByDataType(mdt));
|
||||||
|
} catch (DataTypeNotSupportedException e) {
|
||||||
|
//do nothing
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
tasks = manager.processTasks(tasks);
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.bvn13.imdbspider.exceptions;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class ImdbSpiderException extends Exception {
|
||||||
|
|
||||||
|
public ImdbSpiderException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImdbSpiderException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImdbSpiderException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImdbSpiderException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImdbSpiderException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package ru.bvn13.imdbspider.exceptions.api;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.ImdbSpiderException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class DataTypeNotSupportedException extends ImdbSpiderException {
|
||||||
|
|
||||||
|
public DataTypeNotSupportedException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTypeNotSupportedException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTypeNotSupportedException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTypeNotSupportedException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTypeNotSupportedException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.bvn13.imdbspider.exceptions.extractor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class ConnectionEstablishingException extends HtmlExtractorException {
|
||||||
|
|
||||||
|
public ConnectionEstablishingException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionEstablishingException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionEstablishingException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionEstablishingException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ConnectionEstablishingException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package ru.bvn13.imdbspider.exceptions.extractor;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.ImdbSpiderException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class HtmlExtractorException extends ImdbSpiderException {
|
||||||
|
public HtmlExtractorException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlExtractorException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlExtractorException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlExtractorException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlExtractorException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,27 @@
|
||||||
|
package ru.bvn13.imdbspider.exceptions.extractor;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class MalformedUrlException extends HtmlExtractorException {
|
||||||
|
|
||||||
|
public MalformedUrlException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public MalformedUrlException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MalformedUrlException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MalformedUrlException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public MalformedUrlException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,28 @@
|
||||||
|
package ru.bvn13.imdbspider.exceptions.processor;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.ImdbSpiderException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class HtmlProcessorException extends ImdbSpiderException {
|
||||||
|
|
||||||
|
public HtmlProcessorException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlProcessorException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlProcessorException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlProcessorException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlProcessorException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.bvn13.imdbspider.exceptions.processor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class HtmlToXmlConvertionException extends HtmlProcessorException {
|
||||||
|
|
||||||
|
public HtmlToXmlConvertionException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlToXmlConvertionException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlToXmlConvertionException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlToXmlConvertionException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public HtmlToXmlConvertionException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.bvn13.imdbspider.exceptions.processor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class PatternEvaluationException extends HtmlProcessorException {
|
||||||
|
|
||||||
|
public PatternEvaluationException() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatternEvaluationException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatternEvaluationException(String message, Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatternEvaluationException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public PatternEvaluationException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
|
||||||
|
super(message, cause, enableSuppression, writableStackTrace);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package ru.bvn13.imdbspider.imdb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public interface DataType {
|
||||||
|
|
||||||
|
String get();
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.bvn13.imdbspider.imdb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class ImdbObject {
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setId(int id) {
|
||||||
|
this.id = id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package ru.bvn13.imdbspider.imdb;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class Movie extends ImdbObject {
|
||||||
|
|
||||||
|
private String title;
|
||||||
|
private Map<String, String> akas = new ConcurrentHashMap<>(50);
|
||||||
|
|
||||||
|
|
||||||
|
public String getTitle() {
|
||||||
|
return title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTitle(String title) {
|
||||||
|
this.title = title;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<String, String> getAkas() {
|
||||||
|
return akas;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAkas(Map<String, String> akas) {
|
||||||
|
this.akas = akas;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.bvn13.imdbspider.imdb;
|
||||||
|
|
||||||
|
import java.util.EnumSet;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public enum MovieDataType implements DataType {
|
||||||
|
|
||||||
|
TITLE("title")
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
MovieDataType(String v) {
|
||||||
|
value = v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static final EnumSet<MovieDataType> ALL_DATA = EnumSet.allOf(MovieDataType.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String get() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,10 @@
|
||||||
|
package ru.bvn13.imdbspider.imdb;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class MovieList extends ImdbObject {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package ru.bvn13.imdbspider.spider.api;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.api.DataTypeNotSupportedException;
|
||||||
|
import ru.bvn13.imdbspider.imdb.DataType;
|
||||||
|
import ru.bvn13.imdbspider.imdb.ImdbObject;
|
||||||
|
import ru.bvn13.imdbspider.spider.tasker.Task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public interface ApiFactory {
|
||||||
|
|
||||||
|
Task taskByDataType(DataType dataType) throws DataTypeNotSupportedException;
|
||||||
|
|
||||||
|
void fulfillImdbObject(ImdbObject imdbObject, Task task);
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,47 @@
|
||||||
|
package ru.bvn13.imdbspider.spider.api.v1_0;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.api.DataTypeNotSupportedException;
|
||||||
|
import ru.bvn13.imdbspider.imdb.DataType;
|
||||||
|
import ru.bvn13.imdbspider.imdb.ImdbObject;
|
||||||
|
import ru.bvn13.imdbspider.imdb.Movie;
|
||||||
|
import ru.bvn13.imdbspider.imdb.MovieDataType;
|
||||||
|
import ru.bvn13.imdbspider.spider.api.ApiFactory;
|
||||||
|
import ru.bvn13.imdbspider.spider.tasker.Task;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class ApiFactory_1_0 implements ApiFactory {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Task taskByDataType(DataType dataType) throws DataTypeNotSupportedException {
|
||||||
|
if (dataType instanceof MovieDataType) {
|
||||||
|
return taskByMovieDataType((MovieDataType) dataType);
|
||||||
|
} else {
|
||||||
|
throw new DataTypeNotSupportedException(String.format("DataType %s not supported by API v1_0!", dataType.getClass().getName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void fulfillImdbObject(ImdbObject imdbObject, Task task) {
|
||||||
|
if (imdbObject instanceof Movie) {
|
||||||
|
if (task.getDataType() instanceof MovieDataType) {
|
||||||
|
fulfillMovie((Movie) imdbObject, task);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Task taskByMovieDataType(MovieDataType movieDataType) {
|
||||||
|
switch (movieDataType) {
|
||||||
|
case TITLE: return new Task();
|
||||||
|
default: return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void fulfillMovie(Movie movie, Task task) {
|
||||||
|
switch ((MovieDataType) task.getDataType()) {
|
||||||
|
case TITLE: movie.setTitle(task.getResult()); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,87 @@
|
||||||
|
package ru.bvn13.imdbspider.spider.extractor;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.extractor.HtmlExtractorException;
|
||||||
|
import ru.bvn13.imdbspider.exceptions.extractor.MalformedUrlException;
|
||||||
|
import ru.bvn13.imdbspider.exceptions.extractor.ConnectionEstablishingException;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.*;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class HtmlExtractor {
|
||||||
|
|
||||||
|
private static final String UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36";
|
||||||
|
|
||||||
|
private static String getParamsString(Map<String, String> params) throws UnsupportedEncodingException {
|
||||||
|
StringBuilder result = new StringBuilder();
|
||||||
|
|
||||||
|
for (Map.Entry<String, String> entry : params.entrySet()) {
|
||||||
|
result.append(URLEncoder.encode(entry.getKey(), "UTF-8"));
|
||||||
|
result.append("=");
|
||||||
|
result.append(URLEncoder.encode(entry.getValue(), "UTF-8"));
|
||||||
|
result.append("&");
|
||||||
|
}
|
||||||
|
|
||||||
|
String resultString = result.toString();
|
||||||
|
return resultString.length() > 0
|
||||||
|
? resultString.substring(0, resultString.length() - 1)
|
||||||
|
: resultString;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getHtml(String url) throws HtmlExtractorException {
|
||||||
|
|
||||||
|
URL obj = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
obj = new URL(url);
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
throw new MalformedUrlException(String.format("Wrong url: %s", url), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
HttpURLConnection connection = null;
|
||||||
|
try {
|
||||||
|
connection = (HttpURLConnection) obj.openConnection();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ConnectionEstablishingException(String.format("Unable to open connection by utl: %s", url), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.setRequestProperty("Accept", "text/html");
|
||||||
|
|
||||||
|
try {
|
||||||
|
connection.setRequestMethod("GET");
|
||||||
|
} catch (ProtocolException e) {
|
||||||
|
throw new ConnectionEstablishingException(String.format("Wrong protocol GET for utl: %s", url), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader in = null;
|
||||||
|
try {
|
||||||
|
String inputLine;
|
||||||
|
StringBuilder response = new StringBuilder();
|
||||||
|
in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
|
||||||
|
while ((inputLine = in.readLine()) != null) {
|
||||||
|
response.append(inputLine);
|
||||||
|
}
|
||||||
|
|
||||||
|
return response.toString();
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new ConnectionEstablishingException(String.format("Could not get input stream for utl: %s", url), e);
|
||||||
|
} finally {
|
||||||
|
try {
|
||||||
|
if (in != null) {
|
||||||
|
in.close();
|
||||||
|
}
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,55 @@
|
||||||
|
package ru.bvn13.imdbspider.spider.processor;
|
||||||
|
|
||||||
|
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
import ru.bvn13.imdbspider.exceptions.processor.HtmlProcessorException;
|
||||||
|
import ru.bvn13.imdbspider.exceptions.processor.HtmlToXmlConvertionException;
|
||||||
|
import ru.bvn13.imdbspider.exceptions.processor.PatternEvaluationException;
|
||||||
|
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.xpath.XPath;
|
||||||
|
import javax.xml.xpath.XPathConstants;
|
||||||
|
import javax.xml.xpath.XPathExpressionException;
|
||||||
|
import javax.xml.xpath.XPathFactory;
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class HtmlProcessor {
|
||||||
|
|
||||||
|
public String process(final String html, final String pattern) throws HtmlProcessorException {
|
||||||
|
DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
|
||||||
|
DocumentBuilder db = null;
|
||||||
|
try {
|
||||||
|
db = dbf.newDocumentBuilder();
|
||||||
|
} catch (ParserConfigurationException e) {
|
||||||
|
throw new HtmlProcessorException(e);
|
||||||
|
}
|
||||||
|
Document xml = null;
|
||||||
|
try {
|
||||||
|
xml = db.parse(new ByteArrayInputStream(html.getBytes(StandardCharsets.UTF_8)));
|
||||||
|
} catch (SAXException e) {
|
||||||
|
throw new HtmlToXmlConvertionException("Html parsing exception", e);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new HtmlToXmlConvertionException("Html reading exception", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
XPathFactory xpf = XPathFactory.newInstance();
|
||||||
|
XPath xpath = xpf.newXPath();
|
||||||
|
String result = null;
|
||||||
|
try {
|
||||||
|
result = (String) xpath.evaluate(pattern, xml, XPathConstants.STRING);
|
||||||
|
} catch (XPathExpressionException e) {
|
||||||
|
throw new PatternEvaluationException(String.format("Could not evaluate pattern: %s", pattern), e);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,59 @@
|
||||||
|
package ru.bvn13.imdbspider.spider.tasker;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class Manager {
|
||||||
|
|
||||||
|
private ExecutorService executor;
|
||||||
|
|
||||||
|
public Manager() {
|
||||||
|
this.executor = Executors.newCachedThreadPool();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public List<Task> processTasks(List<Task> allTasks) throws ExecutionException, InterruptedException {
|
||||||
|
|
||||||
|
Map<String, List<Task>> groupedTasks = new ConcurrentHashMap<>(allTasks.size());
|
||||||
|
|
||||||
|
for (Task task : allTasks) {
|
||||||
|
List<Task> filteredTasks = null;
|
||||||
|
|
||||||
|
if (groupedTasks.keySet().contains(task.getUrl())) {
|
||||||
|
filteredTasks = groupedTasks.get(task.getUrl());
|
||||||
|
} else {
|
||||||
|
filteredTasks = new ArrayList<>();
|
||||||
|
groupedTasks.put(task.getUrl(), filteredTasks);
|
||||||
|
}
|
||||||
|
|
||||||
|
filteredTasks.add(task);
|
||||||
|
}
|
||||||
|
|
||||||
|
List<Task> result = Collections.synchronizedList(new ArrayList<>());
|
||||||
|
|
||||||
|
groupedTasks.entrySet().parallelStream().forEach(stringListEntry -> {
|
||||||
|
Future<List<Task>> r = executor.submit(new Worker(stringListEntry.getKey(), stringListEntry.getValue()));
|
||||||
|
while (!r.isDone()) {
|
||||||
|
Thread.yield();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
result.addAll(r.get());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
return result;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,76 @@
|
||||||
|
package ru.bvn13.imdbspider.spider.tasker;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.ImdbSpiderException;
|
||||||
|
import ru.bvn13.imdbspider.imdb.DataType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class Task {
|
||||||
|
|
||||||
|
private String url;
|
||||||
|
|
||||||
|
private String xpathPattern;
|
||||||
|
private DataType dataType;
|
||||||
|
private String result;
|
||||||
|
|
||||||
|
private ImdbSpiderException exception;
|
||||||
|
|
||||||
|
public Task() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task(String xpathPattern) {
|
||||||
|
this.xpathPattern = xpathPattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task(String url, String xpathPattern) {
|
||||||
|
this.url = url;
|
||||||
|
this.xpathPattern = xpathPattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task(String url, String xpathPattern, DataType dataType) {
|
||||||
|
this.url = url;
|
||||||
|
this.xpathPattern = xpathPattern;
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUrl() {
|
||||||
|
return url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setUrl(String url) {
|
||||||
|
this.url = url;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getXpathPattern() {
|
||||||
|
return xpathPattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setXpathPattern(String xpathPattern) {
|
||||||
|
this.xpathPattern = xpathPattern;
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataType getDataType() {
|
||||||
|
return dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDataType(DataType dataType) {
|
||||||
|
this.dataType = dataType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getResult() {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setResult(String result) {
|
||||||
|
this.result = result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ImdbSpiderException getException() {
|
||||||
|
return exception;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setException(ImdbSpiderException exception) {
|
||||||
|
this.exception = exception;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,67 @@
|
||||||
|
package ru.bvn13.imdbspider.spider.tasker;
|
||||||
|
|
||||||
|
import ru.bvn13.imdbspider.exceptions.ImdbSpiderException;
|
||||||
|
import ru.bvn13.imdbspider.exceptions.extractor.HtmlExtractorException;
|
||||||
|
import ru.bvn13.imdbspider.spider.extractor.HtmlExtractor;
|
||||||
|
import ru.bvn13.imdbspider.spider.processor.HtmlProcessor;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.concurrent.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author boyko_vn at 09.01.2019
|
||||||
|
*/
|
||||||
|
public class Worker implements Callable<List<Task>> {
|
||||||
|
|
||||||
|
private final String url;
|
||||||
|
private final List<Task> tasks;
|
||||||
|
|
||||||
|
private final HtmlExtractor htmlExtractor;
|
||||||
|
private final HtmlProcessor htmlProcessor;
|
||||||
|
|
||||||
|
private final ExecutorService executor;
|
||||||
|
|
||||||
|
public Worker(String url, List<Task> tasks) {
|
||||||
|
this.url = url;
|
||||||
|
this.tasks = tasks;
|
||||||
|
|
||||||
|
this.htmlExtractor = new HtmlExtractor();
|
||||||
|
this.htmlProcessor = new HtmlProcessor();
|
||||||
|
|
||||||
|
this.executor = Executors.newCachedThreadPool();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Task> call() throws Exception {
|
||||||
|
Future<String> result = executor.submit(() -> htmlExtractor.getHtml(url));
|
||||||
|
while (!result.isDone()) {
|
||||||
|
Thread.yield();
|
||||||
|
}
|
||||||
|
|
||||||
|
final String html;
|
||||||
|
try {
|
||||||
|
html = result.get();
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
throw new ImdbSpiderException("Interrupted", e);
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
throw new HtmlExtractorException("Exception has been occurred", e);
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.parallelStream().forEach(task -> {
|
||||||
|
Future<String> taskResult = executor.submit(() -> htmlProcessor.process(html, task.getXpathPattern()));
|
||||||
|
while (!taskResult.isDone()) {
|
||||||
|
Thread.yield();
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
task.setResult(taskResult.get());
|
||||||
|
} catch (InterruptedException e) {
|
||||||
|
task.setException(new ImdbSpiderException("Interrupted", e));
|
||||||
|
} catch (ExecutionException e) {
|
||||||
|
task.setException(new ImdbSpiderException("Exception has been occurred", e));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return tasks;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,26 @@
|
||||||
|
package ru.bvn13.imdbspider.runner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.BeforeClass;
|
||||||
|
import org.junit.Test;
|
||||||
|
import ru.bvn13.imdbspider.ImdbSpider;
|
||||||
|
import ru.bvn13.imdbspider.imdb.Movie;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
|
||||||
|
public class AppTest
|
||||||
|
{
|
||||||
|
private static ImdbSpider spider;
|
||||||
|
|
||||||
|
@BeforeClass
|
||||||
|
public static void initClass() {
|
||||||
|
spider = ImdbSpider.withApi_1_0();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void searchTerminatorTest() {
|
||||||
|
List<Movie> result = spider.searchMovieByTitle("Терминатор", 5);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,108 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>ru.bvn13.imdbspider</groupId>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<modules>
|
||||||
|
<module>core</module>
|
||||||
|
<module>runner</module>
|
||||||
|
</modules>
|
||||||
|
|
||||||
|
<name>IMDB-SPIDER :: PARENT</name>
|
||||||
|
<!-- FIXME change it to the project's website -->
|
||||||
|
<url>http://www.example.com</url>
|
||||||
|
|
||||||
|
<packaging>pom</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<java.version>11</java.version>
|
||||||
|
<maven.compiler.source>${java.version}</maven.compiler.source>
|
||||||
|
<maven.compiler.target>${java.version}</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mockito</groupId>
|
||||||
|
<artifactId>mockito-core</artifactId>
|
||||||
|
<version>2.20.0</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
|
||||||
|
<plugins>
|
||||||
|
<!-- clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-clean-plugin</artifactId>
|
||||||
|
<version>3.1.0</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-resources-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.0</version>
|
||||||
|
<configuration>
|
||||||
|
<release>${java.version}</release>
|
||||||
|
</configuration>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
<artifactId>asm</artifactId>
|
||||||
|
<version>6.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-surefire-plugin</artifactId>
|
||||||
|
<version>2.22.1</version>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.ow2.asm</groupId>
|
||||||
|
<artifactId>asm</artifactId>
|
||||||
|
<version>6.2</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-jar-plugin</artifactId>
|
||||||
|
<version>3.0.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-install-plugin</artifactId>
|
||||||
|
<version>2.5.2</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-deploy-plugin</artifactId>
|
||||||
|
<version>2.8.2</version>
|
||||||
|
</plugin>
|
||||||
|
<!-- site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-site-plugin</artifactId>
|
||||||
|
<version>3.7.1</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-project-info-reports-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
|
@ -0,0 +1,86 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<parent>
|
||||||
|
<artifactId>parent</artifactId>
|
||||||
|
<groupId>ru.bvn13.imdbspider</groupId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</parent>
|
||||||
|
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<artifactId>imdb-spider-runner</artifactId>
|
||||||
|
|
||||||
|
<name>IMDB-SPIDER :: RUNNER</name>
|
||||||
|
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>ru.bvn13.imdbspider</groupId>
|
||||||
|
<artifactId>imdb-spider-core</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>4.11</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<!--<build>-->
|
||||||
|
<!--<pluginManagement><!– lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) –>-->
|
||||||
|
<!--<plugins>-->
|
||||||
|
<!--<!– clean lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#clean_Lifecycle –>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-clean-plugin</artifactId>-->
|
||||||
|
<!--<version>3.1.0</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--<!– default lifecycle, jar packaging: see https://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_jar_packaging –>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-resources-plugin</artifactId>-->
|
||||||
|
<!--<version>3.0.2</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-compiler-plugin</artifactId>-->
|
||||||
|
<!--<version>3.8.0</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-surefire-plugin</artifactId>-->
|
||||||
|
<!--<version>2.22.1</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-jar-plugin</artifactId>-->
|
||||||
|
<!--<version>3.0.2</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-install-plugin</artifactId>-->
|
||||||
|
<!--<version>2.5.2</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-deploy-plugin</artifactId>-->
|
||||||
|
<!--<version>2.8.2</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--<!– site lifecycle, see https://maven.apache.org/ref/current/maven-core/lifecycles.html#site_Lifecycle –>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-site-plugin</artifactId>-->
|
||||||
|
<!--<version>3.7.1</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--<plugin>-->
|
||||||
|
<!--<artifactId>maven-project-info-reports-plugin</artifactId>-->
|
||||||
|
<!--<version>3.0.0</version>-->
|
||||||
|
<!--</plugin>-->
|
||||||
|
<!--</plugins>-->
|
||||||
|
<!--</pluginManagement>-->
|
||||||
|
<!--</build>-->
|
||||||
|
</project>
|
|
@ -0,0 +1,5 @@
|
||||||
|
module imdb.spider.runner {
|
||||||
|
requires imdb.spider.core;
|
||||||
|
requires java.xml;
|
||||||
|
|
||||||
|
}
|
|
@ -0,0 +1,13 @@
|
||||||
|
package ru.bvn13.imdbspider.runner;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Hello world!
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class App
|
||||||
|
{
|
||||||
|
public static void main( String[] args )
|
||||||
|
{
|
||||||
|
System.out.println( "Hello World!" );
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,17 @@
|
||||||
|
package ru.bvn13.imdbspider.runner;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class AppTest
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Rigorous Test :-)
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void shouldAnswerWithTrue()
|
||||||
|
{
|
||||||
|
assertTrue( true );
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue