generated from Nekojimi/JavaMavenTemplate
Added a searcher that attempts to use search engines as a proxy.
This commit is contained in:
parent
b8336c26fb
commit
c60d1bfdfa
|
@ -10,6 +10,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
import moe.nekojimi.musicsearcher.Query;
|
||||
import moe.nekojimi.musicsearcher.Result;
|
||||
|
||||
/**
|
||||
|
@ -29,7 +30,7 @@ public class MetaSearcher extends Searcher
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Result> doSearch(String query)
|
||||
protected List<Result> doSearch(Query query)
|
||||
{
|
||||
List<Result> results = new ArrayList<>();
|
||||
List<CompletableFuture<List<Result>>> searches = new ArrayList<>();
|
||||
|
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* To change this license header, choose License Headers in Project Properties.
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package moe.nekojimi.musicsearcher.providers;
|
||||
|
||||
import com.amihaiemil.eoyaml.YamlMapping;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import moe.nekojimi.musicsearcher.parsers.HTMLParser;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jim
|
||||
*/
|
||||
public class SearchHackSearcher extends WebScraperSearcher
|
||||
{
|
||||
|
||||
private final String site;
|
||||
|
||||
public SearchHackSearcher(YamlMapping yaml) throws MalformedURLException
|
||||
{
|
||||
super(yaml.string("name"));
|
||||
searchUrl = "https://html.duckduckgo.com/html/";
|
||||
rootURL = new URL(searchUrl);
|
||||
parser = new HTMLParser();
|
||||
site = yaml.string("site");
|
||||
|
||||
resultSelector = "div.result";
|
||||
resultTitleSelector = ".result__title";
|
||||
resultLinkSelector = ".result__url";
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String transformSearchString(String search)
|
||||
{
|
||||
return "site:"+site + " " + search;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
Loading…
Reference in New Issue