improved search module

This commit is contained in:
huangjx
2022-02-26 21:47:18 +08:00
parent ea07560b5e
commit 0d689ca2dd
6 changed files with 66 additions and 25 deletions

View File

@@ -3,25 +3,26 @@
namespace OCA\NCDownloader\Search\Sites;
//bitsearch.to
class bitSearch implements searchBase
class bitSearch extends searchBase implements searchInterface
{
//html content
private $content = null;
public $baseUrl = "https://bitsearch.to/search";
private $query = null;
protected $query = null;
protected $tableTitles = [];
public function __construct($crawler, $client)
{
$this->client = $client;
$this->crawler = $crawler;
}
public function search($keyword)
public function search(string $keyword): array
{
$this->query = ['q' => trim($keyword), 'sort' => 'seeders'];
$this->searchUrl = $this->baseUrl;
//$this->setContent(file_get_contents(__DIR__ . "/BitSearch.html"));
$this->crawler->add($this->getContent());
return $this->parse();
$this->getItems()->addActionLinks(null);
return ['title' =>$this->getTableTitles(), 'row' => $this->getRows()];
}
public function setContent($content)
{
@@ -35,6 +36,7 @@ class bitSearch implements searchBase
$response = $this->client->request('GET', $this->searchUrl, ['query' => $this->query]);
return $response->getContent();
}
public function parse()
{
@@ -62,4 +64,9 @@ class bitSearch implements searchBase
});
return $data;
}
public function getItems()
{
$this->rows = $this->parse();
return $this;
}
}