generated from Nekojimi/JavaMavenTemplate
parent
b8336c26fb
commit
c60d1bfdfa
@ -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