Closed olivierobert closed 1 year ago
Yes, I makes more sense to put the URL in the Searcher class. I am planning to use a class variable inside this class to have the URL like below
class GoogleSearcher implements Searcher
{
protected WebDriver $driver;
protected string URL = ''https://www.google.com/search?hl=en&q='';
}
It's a bit like hardcoding the URL. Which is sometimes discouraged.
Another way would be to read the value from .env and push it through the constructor by a config class.
I am assuming google won't change the search URL anytime soon. So, I am thinking about implementing the first solution. What's your thoughts on that?
In this case, declaring a static constant (or attribute as suggested) in the class would be sufficient as the value would indeed not change.
Issue
https://github.com/mosharaf13/fleet-searcher/blob/dc70169cf85dd164c55b9b25b355c34390aa04f2/app/Http/Controllers/SearcherController.php#L39
The URL would make more sense to be defined in Searcher class. It seems out of place in the controller. Provided there would be multiple search providers, then each Search class should know to have all data to generate scraping URLs.