File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 99from selenium .webdriver .support import expected_conditions as EC
1010
1111
12+ def is_firefox_installed_as_snap ():
13+ try :
14+ result = subprocess .run (
15+ ["snap" , "list" , "firefox" ],
16+ stdout = subprocess .PIPE ,
17+ stderr = subprocess .PIPE ,
18+ text = True
19+ )
20+ return result .returncode == 0 # Return code 0 means Firefox is installed as a snap
21+ except FileNotFoundError :
22+ print ("Snap is not installed on this system." )
23+ return False
24+
1225if __name__ == "__main__" :
1326 url = "https://animefire.plus/pesquisar/" + "-" .join (input ("Pesquisar anime: " ).split ())
1427 print ("Buscando..." )
3447
3548 url_episode = episode_links [int (selected ) - 1 ]
3649 print ("Procurando video em:" , url_episode )
37- options = webdriver .FirefoxOptions ()
50+ options = webdriver .FirefoxOptions ()
3851 options .add_argument ("--headless" )
39- driver = webdriver .Firefox (options = options )
52+ if is_firefox_installed_as_snap ():
53+ service = webdriver .FirefoxService (executable_path = "/snap/bin/geckodriver" )
54+ driver = webdriver .Firefox (options = options , service = service )
55+ else :
56+ driver = webdriver .Firefox (options = options )
4057 driver .get (url_episode )
4158
4259 try :
You can’t perform that action at this time.
0 commit comments