tasos-py / Search-Engines-Scraper

Search google, bing, yahoo, and other search engines with python
MIT License
547 stars 148 forks source link

Filename argument in search_engines_cli.py #7

Closed nikolasj5 closed 4 years ago

nikolasj5 commented 4 years ago

Hello, thank you very much for this amazing project!

I'm using the search_engines_cli.py and when the query text is too long it gives an error because of file system limit of characters. Fixed for me adding an argument:

ap.add_argument('-n', help='filename for output file', default=cfg.OUTPUT_DIR+'output')

Also added a new require and an argument in engine.output in order to run fine.

Making a pull request as suggestion.

Thank you o/

tasos-py commented 4 years ago

Thanks for your contribution!

I'd like to merge your pull request, but I can see a small issue. In your search_engines_cli.py, line 3, config is imported outside of the try block, and if the lib is not installed it will throw an import error. We still trhow an exception if the lib is not installed, but there is a small "Please install search_engines to resolve this error." message, that might be helpful for some users.

You could simply remove line 3 and use the imported config in line 8 or if you want, import it as cfg and rename config.SEARCH_ENGINE_RESULTS_PAGES, config.PROXY and config.TIMEOUT. Eitherway, I think it's best to have imports in a try/except block.

nikolasj5 commented 4 years ago

My mistake.. didn't see the imports there. And it makes much more sense having them in a try block.

Thank you, Tasos!

tasos-py commented 4 years ago

No problem! I merged you pull request, everything looks good. Thanks again for spotting the issue and offering a solution!