Mohammed Foud
commited on
Commit
·
a255907
1
Parent(s):
55a404c
app1
Browse files
s.py
CHANGED
|
@@ -1,39 +1,63 @@
|
|
| 1 |
-
import time
|
| 2 |
-
from g4f.Provider.bing import CreateImagesBing
|
| 3 |
|
|
|
|
| 4 |
|
| 5 |
-
|
| 6 |
-
def __init__(self, prompt, max_attempts=5):
|
| 7 |
-
self.prompt = prompt
|
| 8 |
-
self.max_attempts = max_attempts
|
| 9 |
-
self.results = []
|
| 10 |
|
| 11 |
-
|
| 12 |
-
attempts = 0
|
| 13 |
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
|
| 19 |
-
|
| 20 |
-
self.results.extend(result_generator)
|
| 21 |
|
| 22 |
-
|
| 23 |
-
|
| 24 |
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
print(f"Error during image creation (Attempt {attempts + 1}/{self.max_attempts})")
|
| 28 |
-
attempts += 1
|
| 29 |
|
| 30 |
-
# For the first attempt, add a delay
|
| 31 |
-
if attempts == 1:
|
| 32 |
-
time.sleep(1) # Add a delay between attempts if needed
|
| 33 |
|
| 34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
|
|
|
|
|
|
|
| 36 |
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
import undetected_chromedriver as uc
|
| 3 |
|
| 4 |
+
options = uc.ChromeOptions()
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5 |
|
| 6 |
+
user_agent = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/118.0.0.0 Safari/537.36'
|
|
|
|
| 7 |
|
| 8 |
+
options = uc.ChromeOptions()
|
| 9 |
+
options.add_argument('--headless')
|
| 10 |
+
options.add_argument('window-size=1400,1500')
|
| 11 |
+
options.add_argument('--disable-gpu')
|
| 12 |
+
options.add_argument('--no-sandbox')
|
| 13 |
+
options.add_argument('start-maximized')
|
| 14 |
+
options.add_argument('enable-automation')
|
| 15 |
+
options.add_argument('--disable-infobars')
|
| 16 |
+
options.add_argument('--disable-dev-shm-usage')
|
| 17 |
+
options.add_argument('--remote-debugging-port=9222')
|
| 18 |
+
options.add_argument('--user-data-dir=/home/ubuntu/chrome_profiles')
|
| 19 |
|
| 20 |
+
driver = uc.Chrome(options=options, version_main=110)
|
|
|
|
| 21 |
|
| 22 |
+
driver.get('https://nowsecure.nl')
|
| 23 |
+
driver.save_screenshot('screen.png')
|
| 24 |
|
| 25 |
+
# import time
|
| 26 |
+
# from g4f.Provider.bing import CreateImagesBing
|
|
|
|
|
|
|
| 27 |
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
+
# class ImageTextGenerator:
|
| 30 |
+
# def __init__(self, prompt, max_attempts=5):
|
| 31 |
+
# self.prompt = prompt
|
| 32 |
+
# self.max_attempts = max_attempts
|
| 33 |
+
# self.results = []
|
| 34 |
|
| 35 |
+
# def generate_images_text(self):
|
| 36 |
+
# attempts = 0
|
| 37 |
|
| 38 |
+
# while attempts < self.max_attempts:
|
| 39 |
+
# try:
|
| 40 |
+
# bing_images_provider = CreateImagesBing()
|
| 41 |
+
# result_generator = bing_images_provider.create_completion(prompt=self.prompt)
|
| 42 |
+
|
| 43 |
+
# # Collect results in a list
|
| 44 |
+
# self.results.extend(result_generator)
|
| 45 |
+
|
| 46 |
+
# # Successful execution, break the loop
|
| 47 |
+
# break
|
| 48 |
+
|
| 49 |
+
# except (RuntimeError, Exception) as e:
|
| 50 |
+
# print(f"Error: {e}")
|
| 51 |
+
# print(f"Error during image creation (Attempt {attempts + 1}/{self.max_attempts})")
|
| 52 |
+
# attempts += 1
|
| 53 |
+
|
| 54 |
+
# # For the first attempt, add a delay
|
| 55 |
+
# if attempts == 1:
|
| 56 |
+
# time.sleep(1) # Add a delay between attempts if needed
|
| 57 |
+
|
| 58 |
+
# return self.results
|
| 59 |
+
|
| 60 |
+
|
| 61 |
+
# print("sssssssssssssssssss1111")
|
| 62 |
+
# s = ImageTextGenerator("red Cow").generate_images_text()
|
| 63 |
+
# print("sssssssssssssssssss", s)
|