Yusin commited on
Commit
68e3d6c
1 Parent(s): fb0ec11

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +45 -0
main.py CHANGED
@@ -1,5 +1,50 @@
 
 
1
  import os
2
  session_token = os.environ.get('SessionToken')
3
  conversation_id = os.environ.get('conversation_id')
4
  from revChatGPT.ChatGPT import Chatbot
5
  chatbot = Chatbot({"session_token": session_token}) # You can start a custom conversation
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ '''
3
  import os
4
  session_token = os.environ.get('SessionToken')
5
  conversation_id = os.environ.get('conversation_id')
6
  from revChatGPT.ChatGPT import Chatbot
7
  chatbot = Chatbot({"session_token": session_token}) # You can start a custom conversation
8
+ '''
9
+
10
+ import undetected_chromedriver.v2 as uc
11
+ from selenium.webdriver.support import expected_conditions as EC
12
+ from selenium.webdriver.support.ui import WebDriverWait
13
+ from selenium.webdriver.common.by import By
14
+
15
+
16
+ def get_element_or_none(driver, xpath, wait=None):
17
+ try:
18
+ if wait is None:
19
+ return driver.find_element(By.XPATH, xpath)
20
+ else:
21
+ return WebDriverWait(driver, wait).until(
22
+ EC.presence_of_element_located((By.XPATH, xpath)))
23
+ except:
24
+ return None
25
+
26
+
27
+ def run():
28
+ print("Welcome to game of Tom and Jerry. Here Cloudflare is the cat, Jerry is the Programmer. Our Goal as a good Jerry is to trick Cloudflare.")
29
+
30
+ options = uc.ChromeOptions()
31
+ options.arguments.extend(
32
+ ["--no-sandbox", "--disable-setuid-sandbox"])
33
+ print("Creating Driver...")
34
+ driver = uc.Chrome(
35
+ options=options
36
+ )
37
+ print("Created Driver...")
38
+
39
+ driver.get('https://nowsecure.nl')
40
+
41
+ element = get_element_or_none(driver, "/html/body/div[2]/div/main/h1", 20)
42
+ if element is not None:
43
+ print("We defeated Cloudflare, 🎉🥳 :)")
44
+ else:
45
+ print("Cloudflare defeated us :(, No woory we will try again. ")
46
+ driver.quit()
47
+
48
+
49
+ if __name__ == "__main__":
50
+ run()