From e29c47720c8460466e76ba34e8cee2dbec420bef Mon Sep 17 00:00:00 2001 From: ege Date: Tue, 23 Mar 2021 13:51:07 +0300 Subject: [PATCH] added package fake_useragent --- inscrawler/browser.py | 2 ++ requirements.txt | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/inscrawler/browser.py b/inscrawler/browser.py index e139b03..ab52503 100644 --- a/inscrawler/browser.py +++ b/inscrawler/browser.py @@ -11,6 +11,7 @@ from .utils import randmized_sleep +from fake_useragent import UserAgent class Browser: def __init__(self, has_screen): @@ -21,6 +22,7 @@ def __init__(self, has_screen): chrome_options.add_argument("--headless") chrome_options.add_argument("--start-maximized") chrome_options.add_argument("--no-sandbox") + chrome_options.add_argument("user-agent="+UserAgent().random) self.driver = webdriver.Chrome( executable_path="%s/bin/chromedriver" % dir_path, service_args=service_args, diff --git a/requirements.txt b/requirements.txt index 0ce9a2f..df1ca63 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,4 +2,5 @@ future==0.16.0 selenium==3.9.0 tqdm==4.23.4 pre-commit==1.16.1 -black==19.3b0 \ No newline at end of file +black==19.3b0 +fake-useragent==0.1.11 \ No newline at end of file