🏗️ Allow access to Config from Collectors
This commit is contained in:
@@ -22,13 +22,13 @@ class YahooImageCollector extends Collector
|
||||
*/
|
||||
public function getRandomImage()
|
||||
{
|
||||
$word_to_search = $this->generateRandomWord();
|
||||
$word_to_search = $this->getConfig()->get('collector.keywords.keywords', $this->generateRandomWord());
|
||||
|
||||
$client = new Client();
|
||||
$crawler = $client->request('GET', sprintf(self::SEARCH_URL, $word_to_search));
|
||||
$imgs = $crawler->filter('noscript img');
|
||||
if ($imgs->count() < 20) {
|
||||
return $this->getRandomImage();
|
||||
return $this->getRandomImage(); // FIXME possible infinite loop if keywords is given
|
||||
}
|
||||
|
||||
$img_url = $imgs->eq(random_int(0, $imgs->count() - 1))->attr('src');
|
||||
|
Reference in New Issue
Block a user