Skip to content

Commit

Permalink
Merge pull request #21 from shaikhsajid1111/user-agent-issue
Browse files Browse the repository at this point in the history
Fix for User agent issue
  • Loading branch information
shaikhsajid1111 authored Jun 13, 2022
2 parents aaf9523 + 395dfb2 commit 84ec015
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
python-dateutil==2.8.1
selenium==3.141.0
selenium-wire==4.3.1
webdriver-manager==3.2.2
webdriver-manager==3.2.2
fake-headers==1.0.2
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

setuptools.setup(
name="twitter_scraper_selenium",
version="0.1.6",
version="0.1.7",
author="Sajid Shaikh",
author_email="[email protected]",
description="Python package to scrap twitter's front-end easily with selenium",
Expand Down
3 changes: 3 additions & 0 deletions twitter_scraper_selenium/driver_initialization.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
# import webdriver for downloading respective driver for the browser
from webdriver_manager.chrome import ChromeDriverManager
from webdriver_manager.firefox import GeckoDriverManager
from fake_headers import Headers
except Exception as ex:
print(ex)

Expand All @@ -19,6 +20,7 @@ def __init__(self, browser_name, proxy=None):

def set_properties(self, browser_option):
"""adds capabilities to the driver"""
header = Headers().generate()['User-Agent']
browser_option.add_argument(
'--headless') # runs browser in headless mode
browser_option.add_argument('--no-sandbox')
Expand All @@ -28,6 +30,7 @@ def set_properties(self, browser_option):
browser_option.add_argument('--log-level=3')
browser_option.add_argument('--disable-notifications')
browser_option.add_argument('--disable-popup-blocking')
browser_option.add_argument('--user-agent={}'.format(header))
return browser_option

def set_driver_for_browser(self, browser_name):
Expand Down

0 comments on commit 84ec015

Please sign in to comment.