Search in sources :

Example 81 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project jabref by JabRef.

the class GoogleScholar method performSearch.

@Override
public List<BibEntry> performSearch(String query) throws FetcherException {
    try {
        obtainAndModifyCookie();
        List<BibEntry> foundEntries = new ArrayList<>(10);
        URIBuilder uriBuilder = new URIBuilder(BASIC_SEARCH_URL);
        uriBuilder.addParameter("hl", "en");
        uriBuilder.addParameter("btnG", "Search");
        uriBuilder.addParameter("q", query);
        addHitsFromQuery(foundEntries, uriBuilder.toString());
        if (foundEntries.size() == 10) {
            uriBuilder.addParameter("start", "10");
            addHitsFromQuery(foundEntries, uriBuilder.toString());
        }
        return foundEntries;
    } catch (URISyntaxException e) {
        throw new FetcherException("Error while fetching from " + getName(), e);
    } catch (IOException e) {
        // java.io.IOException: Server returned HTTP response code: 503 for URL: https://ipv4.google.com/sorry/index?continue=https://scholar.google.com/scholar%3Fhl%3Den%26btnG%3DSearch%26q%3Dbpmn&hl=en&q=CGMSBI0NBDkYuqy9wAUiGQDxp4NLQCWbIEY1HjpH5zFJhv4ANPGdWj0
        if (e.getMessage().contains("Server returned HTTP response code: 503 for URL")) {
            throw new FetcherException("Fetching from Google Scholar failed.", Localization.lang("This might be caused by reaching the traffic limitation of Google Scholar (see 'Help' for details)."), e);
        } else {
            throw new FetcherException("Error while fetching from " + getName(), e);
        }
    }
}
Also used : BibEntry(org.jabref.model.entry.BibEntry) FetcherException(org.jabref.logic.importer.FetcherException) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) IOException(java.io.IOException) URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 82 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project jabref by JabRef.

the class GvkFetcher method getURLForQuery.

@Override
public URL getURLForQuery(String query) throws URISyntaxException, MalformedURLException, FetcherException {
    String gvkQuery = getSearchQueryString(query);
    URIBuilder uriBuilder = new URIBuilder(URL_PATTERN);
    uriBuilder.addParameter("version", "1.1");
    uriBuilder.addParameter("operation", "searchRetrieve");
    uriBuilder.addParameter("query", gvkQuery);
    uriBuilder.addParameter("maximumRecords", "50");
    uriBuilder.addParameter("recordSchema", "picaxml");
    uriBuilder.addParameter("sortKeys", "Year,,1");
    return uriBuilder.build().toURL();
}
Also used : URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 83 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project jabref by JabRef.

the class MedlineFetcher method createSearchUrl.

private URL createSearchUrl(String term) throws URISyntaxException, MalformedURLException {
    term = replaceCommaWithAND(term);
    URIBuilder uriBuilder = new URIBuilder(SEARCH_URL);
    uriBuilder.addParameter("db", "pubmed");
    uriBuilder.addParameter("sort", "relevance");
    uriBuilder.addParameter("retmax", String.valueOf(NUMBER_TO_FETCH));
    uriBuilder.addParameter("term", term);
    return uriBuilder.build().toURL();
}
Also used : URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 84 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project jabref by JabRef.

the class IsbnViaEbookDeFetcher method getURLForID.

@Override
public URL getURLForID(String identifier) throws URISyntaxException, MalformedURLException, FetcherException {
    this.ensureThatIsbnIsValid(identifier);
    URIBuilder uriBuilder = new URIBuilder("http://www.ebook.de/de/tools/isbn2bibtex");
    uriBuilder.addParameter("isbn", identifier);
    return uriBuilder.build().toURL();
}
Also used : URIBuilder(org.apache.http.client.utils.URIBuilder)

Example 85 with URIBuilder

use of org.apache.http.client.utils.URIBuilder in project jabref by JabRef.

the class MathSciNet method getURLForID.

@Override
public URL getURLForID(String identifier) throws URISyntaxException, MalformedURLException, FetcherException {
    URIBuilder uriBuilder = new URIBuilder("http://www.ams.org/mathscinet/search/publications.html");
    // search MR number
    uriBuilder.addParameter("pg1", "MR");
    // identifier
    uriBuilder.addParameter("s1", identifier);
    // BibTeX format
    uriBuilder.addParameter("fmt", "bibtex");
    return uriBuilder.build().toURL();
}
Also used : URIBuilder(org.apache.http.client.utils.URIBuilder)

Aggregations

URIBuilder (org.apache.http.client.utils.URIBuilder)107 URISyntaxException (java.net.URISyntaxException)42 URI (java.net.URI)37 HttpGet (org.apache.http.client.methods.HttpGet)22 IOException (java.io.IOException)21 NameValuePair (org.apache.http.NameValuePair)13 HttpEntity (org.apache.http.HttpEntity)10 NotNull (org.jetbrains.annotations.NotNull)9 Map (java.util.Map)8 CloseableHttpResponse (org.apache.http.client.methods.CloseableHttpResponse)8 ArrayList (java.util.ArrayList)7 HashMap (java.util.HashMap)7 HttpResponse (org.apache.http.HttpResponse)7 List (java.util.List)6 HttpClient (org.apache.http.client.HttpClient)5 CloseableHttpClient (org.apache.http.impl.client.CloseableHttpClient)5 Gson (com.google.gson.Gson)4 URL (java.net.URL)4 RequestConfig (org.apache.http.client.config.RequestConfig)4 HttpPost (org.apache.http.client.methods.HttpPost)4