conditional ChromeDriver Installation
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
fake_headers==1.0.2
|
fake_headers>=1.0.2
|
||||||
pandas==2.0.3
|
pandas>=2.0.3
|
||||||
python-dotenv==1.0.0
|
python-dotenv>=1.0.0
|
||||||
selenium==4.12.0
|
selenium>=4.12.0
|
||||||
webdriver_manager==4.0.0
|
webdriver_manager>=4.0.0
|
||||||
|
|||||||
@@ -52,20 +52,29 @@ class Twitter_Scraper():
|
|||||||
browser_option.add_argument("--headless")
|
browser_option.add_argument("--headless")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
print("Downloading ChromeDriver...")
|
|
||||||
chromedriver_path = ChromeDriverManager().install()
|
|
||||||
chrome_service = ChromeService(executable_path=chromedriver_path)
|
|
||||||
|
|
||||||
print("Initializing ChromeDriver...")
|
print("Initializing ChromeDriver...")
|
||||||
driver = webdriver.Chrome(
|
driver = webdriver.Chrome(
|
||||||
service=chrome_service,
|
|
||||||
options=browser_option,
|
options=browser_option,
|
||||||
)
|
)
|
||||||
|
|
||||||
return driver
|
return driver
|
||||||
except Exception as e:
|
except WebDriverException:
|
||||||
print(f"Error setting up WebDriver: {e}")
|
try:
|
||||||
sys.exit(1)
|
print("Downloading ChromeDriver...")
|
||||||
|
chromedriver_path = ChromeDriverManager().install()
|
||||||
|
chrome_service = ChromeService(
|
||||||
|
executable_path=chromedriver_path)
|
||||||
|
|
||||||
|
print("Initializing ChromeDriver...")
|
||||||
|
driver = webdriver.Chrome(
|
||||||
|
service=chrome_service,
|
||||||
|
options=browser_option,
|
||||||
|
)
|
||||||
|
|
||||||
|
return driver
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error setting up WebDriver: {e}")
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
def _login(self):
|
def _login(self):
|
||||||
print("Logging in to Twitter...")
|
print("Logging in to Twitter...")
|
||||||
@@ -76,6 +85,9 @@ class Twitter_Scraper():
|
|||||||
self._input_username()
|
self._input_username()
|
||||||
self._input_unusual_activity()
|
self._input_unusual_activity()
|
||||||
self._input_password()
|
self._input_password()
|
||||||
|
|
||||||
|
print("Login Successful")
|
||||||
|
print()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def _input_username(self):
|
def _input_username(self):
|
||||||
@@ -96,7 +108,7 @@ class Twitter_Scraper():
|
|||||||
input_attempt += 1
|
input_attempt += 1
|
||||||
if input_attempt >= 3:
|
if input_attempt >= 3:
|
||||||
print()
|
print()
|
||||||
print(""""
|
print("""
|
||||||
There was an error inputting the username.
|
There was an error inputting the username.
|
||||||
|
|
||||||
It may be due to the following:
|
It may be due to the following:
|
||||||
@@ -177,8 +189,6 @@ It may be due to the following:
|
|||||||
callback()
|
callback()
|
||||||
|
|
||||||
print("Scraping Tweets...")
|
print("Scraping Tweets...")
|
||||||
print()
|
|
||||||
|
|
||||||
self.progress.print_progress(0)
|
self.progress.print_progress(0)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
|||||||
Reference in New Issue
Block a user