conditional ChromeDriver Installation
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
fake_headers==1.0.2
|
||||
pandas==2.0.3
|
||||
python-dotenv==1.0.0
|
||||
selenium==4.12.0
|
||||
webdriver_manager==4.0.0
|
||||
fake_headers>=1.0.2
|
||||
pandas>=2.0.3
|
||||
python-dotenv>=1.0.0
|
||||
selenium>=4.12.0
|
||||
webdriver_manager>=4.0.0
|
||||
|
||||
@@ -51,10 +51,19 @@ class Twitter_Scraper():
|
||||
# For Hiding Browser
|
||||
browser_option.add_argument("--headless")
|
||||
|
||||
try:
|
||||
print("Initializing ChromeDriver...")
|
||||
driver = webdriver.Chrome(
|
||||
options=browser_option,
|
||||
)
|
||||
|
||||
return driver
|
||||
except WebDriverException:
|
||||
try:
|
||||
print("Downloading ChromeDriver...")
|
||||
chromedriver_path = ChromeDriverManager().install()
|
||||
chrome_service = ChromeService(executable_path=chromedriver_path)
|
||||
chrome_service = ChromeService(
|
||||
executable_path=chromedriver_path)
|
||||
|
||||
print("Initializing ChromeDriver...")
|
||||
driver = webdriver.Chrome(
|
||||
@@ -76,6 +85,9 @@ class Twitter_Scraper():
|
||||
self._input_username()
|
||||
self._input_unusual_activity()
|
||||
self._input_password()
|
||||
|
||||
print("Login Successful")
|
||||
print()
|
||||
pass
|
||||
|
||||
def _input_username(self):
|
||||
@@ -96,7 +108,7 @@ class Twitter_Scraper():
|
||||
input_attempt += 1
|
||||
if input_attempt >= 3:
|
||||
print()
|
||||
print(""""
|
||||
print("""
|
||||
There was an error inputting the username.
|
||||
|
||||
It may be due to the following:
|
||||
@@ -177,8 +189,6 @@ It may be due to the following:
|
||||
callback()
|
||||
|
||||
print("Scraping Tweets...")
|
||||
print()
|
||||
|
||||
self.progress.print_progress(0)
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user