org.hogel.bookscan.BasicConnector Maven / Gradle / Ivy
package org.hogel.bookscan;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import java.io.IOException;
import java.util.Map;
import java.util.TreeMap;
public class BasicConnector implements Connector {
private final Map cookies = new TreeMap<>();
@Override
public Connection connect(String url) {
return Jsoup.connect(url).cookies(cookies);
}
@Override
public Document execute(Connection connection) throws IOException {
Connection.Response response = connection.execute();
cookies.putAll(response.cookies());
return response.parse();
}
@Override
public Map getCookies() {
return cookies;
}
@Override
public void putCookies(Map cookies) {
this.cookies.putAll(cookies);
}
@Override
public void clearCookies() {
cookies.clear();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy