1111 from webdriver_manager .firefox import GeckoDriverManager
1212except Exception :
1313 logging .error (
14- 'Could not import all required modules. ' \
15- 'Please run the following command again:\n \n ' \
14+ 'Could not import all required modules. '
15+ 'Please run the following command again:\n \n '
1616 '\t pipenv install\n ' )
1717 exit ()
1818
19- def get_default_profile ():
19+
20+ def get_profile_path ():
2021 if platform == 'linux' or platform == 'linux2' :
21- mozilla_profile = Path (os .getenv ('HOME' )) / '.mozilla' / 'firefox'
22+ profile_path = Path (os .getenv ('HOME' )) / '.mozilla' / 'firefox'
2223 elif platform == 'darwin' :
23- mozilla_profile = Path (os .getenv ('HOME' )) / \
24+ profile_path = Path (os .getenv ('HOME' )) / \
2425 'Library' / 'Application Support' / 'Firefox'
2526 elif platform == 'win32' :
26- mozilla_profile = Path (os .getenv ('APPDATA' )) / 'Mozilla' / 'Firefox'
27- if not mozilla_profile .exists ():
28- raise FileNotFoundError ("Mozilla profile doesn't exist and/or can't be located on this machine." )
27+ profile_path = Path (os .getenv ('APPDATA' )) / 'Mozilla' / 'Firefox'
28+ if not profile_path .exists ():
29+ raise FileNotFoundError (
30+ "Mozilla profile doesn't exist and/or can't be located on this machine." )
31+ return profile_path
32+
2933
30- mozilla_profile_ini = mozilla_profile / 'profiles.ini'
34+ def get_default_profile (profile_path ):
35+ mozilla_profile_ini = profile_path / 'profiles.ini'
3136 profile = configparser .ConfigParser ()
3237 profile .read (mozilla_profile_ini )
33- return mozilla_profile / profile .get ('Profile0' , 'Path' )
38+ return profile .get ('Profile0' , 'Path' )
3439
3540
3641def prepare_sniper_profile (default_profile_path ):
@@ -42,13 +47,16 @@ def prepare_sniper_profile(default_profile_path):
4247
4348
4449def create ():
45- default_profile_path = get_default_profile ()
46- profile = prepare_sniper_profile (default_profile_path )
47- driver = webdriver .Firefox (firefox_profile = profile , executable_path = GeckoDriverManager ().install ())
50+ profile_path = get_profile_path ()
51+ default_profile = get_default_profile (profile_path )
52+ logging .info (f'Launching Firefox using default profile: { default_profile } ' )
53+ profile = prepare_sniper_profile (profile_path / default_profile )
54+ driver = webdriver .Firefox (
55+ firefox_profile = profile , executable_path = GeckoDriverManager ().install ())
4856 if os .path .isfile ('./recaptcha_solver-5.7-fx.xpi' ):
49- logging .info ('ReCaptcha solver detected, enabled ' )
57+ logging .info ('ReCaptcha solver extension detected and installed ' )
5058 extension_path = os .path .abspath ("recaptcha_solver-5.7-fx.xpi" )
5159 driver .install_addon (extension_path , temporary = True )
5260 else :
53- logging .info ('ReCaptcha solver not found' )
54- return driver
61+ logging .info ('ReCaptcha solver extension not found' )
62+ return driver
0 commit comments