prabinpanta0 commited on
Commit
e539434
1 Parent(s): 0bac7c0

Update form_filler.py

Browse files
Files changed (1) hide show
  1. form_filler.py +12 -2
form_filler.py CHANGED
@@ -29,12 +29,22 @@ class FormFiller:
29
  display = Xvfb(width=1280, height=720)
30
  display.start()
31
 
 
32
  chrome_options = Options()
33
  chrome_options.add_argument("--headless")
34
  chrome_options.add_argument("--no-sandbox")
35
  chrome_options.add_argument("--disable-dev-shm-usage")
36
  chrome_options.add_argument("--disable-gpu")
37
-
 
 
 
 
 
 
 
 
 
38
  driver = webdriver.Chrome(options=chrome_options)
39
  driver.get(url)
40
 
@@ -131,4 +141,4 @@ class FormFiller:
131
  for i in range(remaining_iterations):
132
  futures.append(executor.submit(self.fill_form, url, 1, update_callback, i + 1))
133
  for future in futures:
134
- future.result()
 
29
  display = Xvfb(width=1280, height=720)
30
  display.start()
31
 
32
+ # Modify the chrome options to specify the cache directory
33
  chrome_options = Options()
34
  chrome_options.add_argument("--headless")
35
  chrome_options.add_argument("--no-sandbox")
36
  chrome_options.add_argument("--disable-dev-shm-usage")
37
  chrome_options.add_argument("--disable-gpu")
38
+
39
+ # Create a cache directory if it doesn't exist
40
+ cache_dir = os.path.join(os.getcwd(), '.cache')
41
+ if not os.path.exists(cache_dir):
42
+ os.makedirs(cache_dir)
43
+
44
+ # Specify the cache directory
45
+ chrome_options.add_argument(f"--disk-cache-dir={cache_dir}")
46
+ chrome_options.add_argument(f"--cache-dir={cache_dir}")
47
+
48
  driver = webdriver.Chrome(options=chrome_options)
49
  driver.get(url)
50
 
 
141
  for i in range(remaining_iterations):
142
  futures.append(executor.submit(self.fill_form, url, 1, update_callback, i + 1))
143
  for future in futures:
144
+ future.result()