parsagon 0.16.0__tar.gz → 0.17.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. {parsagon-0.16.0 → parsagon-0.17.0}/PKG-INFO +4 -5
  2. {parsagon-0.16.0 → parsagon-0.17.0}/pyproject.toml +4 -5
  3. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/api.py +3 -1
  4. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/executor.py +57 -3
  5. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/main.py +5 -0
  6. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/runs.py +2 -1
  7. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon.egg-info/PKG-INFO +4 -5
  8. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon.egg-info/requires.txt +3 -4
  9. {parsagon-0.16.0 → parsagon-0.17.0}/README.md +0 -0
  10. {parsagon-0.16.0 → parsagon-0.17.0}/setup.cfg +0 -0
  11. {parsagon-0.16.0 → parsagon-0.17.0}/src/__init__.py +0 -0
  12. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/__init__.py +0 -0
  13. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/assistant.py +0 -0
  14. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/create.py +0 -0
  15. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/custom_function.py +0 -0
  16. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/edit.py +0 -0
  17. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/exceptions.py +0 -0
  18. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/gui/__init__.py +0 -0
  19. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/gui/controller.py +0 -0
  20. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/gui/menu.py +0 -0
  21. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/gui/window.py +0 -0
  22. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/gui_entry.py +0 -0
  23. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/highlights.js +0 -0
  24. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/print.py +0 -0
  25. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/secrets.py +0 -0
  26. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/settings.py +0 -0
  27. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/tests/__init__.py +0 -0
  28. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/tests/api_mocks.py +0 -0
  29. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/tests/conftest.py +0 -0
  30. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/tests/test_executor.py +0 -0
  31. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/tests/test_invalid_args.py +0 -0
  32. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/tests/test_pipeline_operations.py +0 -0
  33. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/tests/test_print.py +0 -0
  34. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon/tests/test_secrets.py +0 -0
  35. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon.egg-info/SOURCES.txt +0 -0
  36. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon.egg-info/dependency_links.txt +0 -0
  37. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon.egg-info/entry_points.txt +0 -0
  38. {parsagon-0.16.0 → parsagon-0.17.0}/src/parsagon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: parsagon
3
- Version: 0.16.0
3
+ Version: 0.17.0
4
4
  Summary: Allows you to create browser automations with natural language
5
5
  Author-email: Sandy Suh <sandy@parsagon.io>
6
6
  Project-URL: Homepage, https://parsagon.io
@@ -8,15 +8,14 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Operating System :: OS Independent
9
9
  Requires-Python: >=3.8
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: seleniumbase==4.38.0
12
- Requires-Dist: selenium>=4.9.1
11
+ Requires-Dist: selenium==4.9.1
13
12
  Requires-Dist: lxml[html_clean]==5.3.2
14
13
  Requires-Dist: httpx>=0.27.0
15
14
  Requires-Dist: psutil==7.0.0
16
- Requires-Dist: rich>=13.6.0
15
+ Requires-Dist: rich==13.6.0
17
16
  Requires-Dist: PyVirtualDisplay==3.0
18
17
  Requires-Dist: selenium-wire==5.1.0
19
- Requires-Dist: cssselect>=1.2.0
18
+ Requires-Dist: cssselect==1.2.0
20
19
  Requires-Dist: undetected-chromedriver==3.5.5
21
20
  Requires-Dist: webdriver-manager==4.0.2
22
21
  Requires-Dist: jsonpath-ng==1.5.3
@@ -16,7 +16,7 @@ line-length = 120
16
16
 
17
17
  [project]
18
18
  name = "parsagon"
19
- version = "0.16.0"
19
+ version = "0.17.0"
20
20
  description = "Allows you to create browser automations with natural language"
21
21
  readme = "README.md"
22
22
  requires-python = ">=3.8"
@@ -29,17 +29,16 @@ classifiers = [
29
29
  ]
30
30
 
31
31
  dependencies = [
32
- 'seleniumbase == 4.38.0',
33
- 'selenium >= 4.9.1',
32
+ 'selenium == 4.9.1',
34
33
  'lxml[html_clean] == 5.3.2',
35
34
  'httpx >= 0.27.0',
36
35
  'psutil == 7.0.0',
37
- 'rich >= 13.6.0',
36
+ 'rich == 13.6.0',
38
37
 
39
38
  # Used only in pipeline code execution
40
39
  'PyVirtualDisplay==3.0',
41
40
  'selenium-wire==5.1.0',
42
- 'cssselect>=1.2.0',
41
+ 'cssselect==1.2.0',
43
42
  'undetected-chromedriver==3.5.5',
44
43
  'webdriver-manager==4.0.2',
45
44
  'jsonpath-ng==1.5.3',
@@ -247,7 +247,7 @@ def get_pipelines():
247
247
  return _api_call(httpx.get, f"/pipelines/")
248
248
 
249
249
 
250
- def get_pipeline_code(pipeline_name, variables, headless, use_uc, optimize, use_proxy, pipeline_id=None):
250
+ def get_pipeline_code(pipeline_name, variables, headless, use_cdp, use_uc, optimize, use_proxy, pipeline_id=None):
251
251
  if pipeline_id:
252
252
  return _api_call(
253
253
  httpx.post,
@@ -255,6 +255,7 @@ def get_pipeline_code(pipeline_name, variables, headless, use_uc, optimize, use_
255
255
  json={
256
256
  "variables": variables,
257
257
  "headless": headless,
258
+ "use_cdp": use_cdp,
258
259
  "use_uc": use_uc,
259
260
  "optimize": optimize,
260
261
  "use_proxy": use_proxy,
@@ -268,6 +269,7 @@ def get_pipeline_code(pipeline_name, variables, headless, use_uc, optimize, use_
268
269
  json={
269
270
  "variables": variables,
270
271
  "headless": headless,
272
+ "use_cdp": use_cdp,
271
273
  "use_uc": use_uc,
272
274
  "optimize": optimize,
273
275
  "use_proxy": use_proxy,
@@ -17,11 +17,17 @@ from lxml import etree
17
17
  import lxml.html
18
18
  from lxml.html.clean import Cleaner
19
19
  from pypdf import PdfReader
20
- from seleniumbase import Driver
20
+ from pyvirtualdisplay import Display
21
+ import undetected_chromedriver as uc
22
+ from selenium import webdriver
23
+ from selenium.webdriver.chrome.service import Service as ChromeService
24
+ from selenium.webdriver.chrome.options import Options
21
25
  from selenium.webdriver.common.action_chains import ActionChains
22
26
  from selenium.webdriver.common.by import By
23
27
  from selenium.webdriver.common.keys import Keys
24
28
  from selenium.webdriver.support.select import Select
29
+ from webdriver_manager.chrome import ChromeDriverManager
30
+ from webdriver_manager.core.driver_cache import DriverCacheManager
25
31
 
26
32
  from parsagon import settings
27
33
  from parsagon.api import (
@@ -76,6 +82,7 @@ class Executor:
76
82
  infer=False,
77
83
  use_uc=False,
78
84
  driver_path=None,
85
+ options=[],
79
86
  page_load_timeout=None,
80
87
  script_timeout=None,
81
88
  function_bank={},
@@ -83,8 +90,43 @@ class Executor:
83
90
  self.task = task
84
91
  self.headless = headless
85
92
  self.function_bank = function_bank
86
- self.driver = Driver(external_pdf=True, undetectable=use_uc)
87
- self.driver.maximize_window()
93
+ if self.headless:
94
+ self.display = Display(visible=False, size=(1280, 1050)).start()
95
+ if driver_path:
96
+ cache_manager = DriverCacheManager(root_dir=driver_path)
97
+ driver_executable_path = ChromeDriverManager(cache_manager=cache_manager).install()
98
+ else:
99
+ driver_executable_path = ChromeDriverManager().install()
100
+ if use_uc:
101
+ chrome_options = uc.ChromeOptions()
102
+ chrome_options.add_argument("--start-maximized")
103
+ for option in options:
104
+ chrome_options.add_argument(option)
105
+ chrome_options.add_experimental_option(
106
+ "prefs",
107
+ {
108
+ "download.default_directory": os.getcwd(),
109
+ "download.prompt_for_download": False,
110
+ "download.directory_upgrade": True,
111
+ "plugins.always_open_pdf_externally": True,
112
+ },
113
+ )
114
+ self.driver = uc.Chrome(driver_executable_path=driver_executable_path, options=chrome_options)
115
+ else:
116
+ chrome_options = webdriver.ChromeOptions()
117
+ chrome_options.add_argument("--start-maximized")
118
+ for option in options:
119
+ chrome_options.add_argument(option)
120
+ chrome_options.add_experimental_option(
121
+ "prefs",
122
+ {
123
+ "download.default_directory": os.getcwd(),
124
+ "download.prompt_for_download": False,
125
+ "download.directory_upgrade": True,
126
+ "plugins.always_open_pdf_externally": True,
127
+ },
128
+ )
129
+ self.driver = webdriver.Chrome(service=ChromeService(driver_executable_path), options=chrome_options)
88
130
  if page_load_timeout:
89
131
  self.driver.set_page_load_timeout(page_load_timeout)
90
132
  if script_timeout:
@@ -115,6 +157,7 @@ class Executor:
115
157
  "get_serp_data": get_serp_data,
116
158
  "get_pdf_text": self.get_pdf_text,
117
159
  "str_to_iso8601": self.str_to_iso8601,
160
+ "get_network_requests": self.get_network_requests,
118
161
  }
119
162
  self.custom_functions = {}
120
163
  self.infer = infer
@@ -671,6 +714,17 @@ class Executor:
671
714
  s = " ".join(s.split()[:-1])
672
715
  return ""
673
716
 
717
+ def get_network_requests(window_id, delay=30):
718
+ requests = []
719
+
720
+ def handle_request(event):
721
+ requests.append(event)
722
+
723
+ driver.switch_to.window(window_id)
724
+ driver.add_cdp_listener("Network.requestWillBeSent", handle_request)
725
+ wait(delay)
726
+ return requests
727
+
674
728
  def execute(self, code):
675
729
  loc = {}
676
730
  try:
@@ -144,6 +144,11 @@ def get_args(argv):
144
144
  type=str,
145
145
  help="write the data to the given file path",
146
146
  )
147
+ parser_run.add_argument(
148
+ "--use_cdp",
149
+ action="store_true",
150
+ help="enable CDP (only in undetected mode)",
151
+ )
147
152
  parser_run.add_argument(
148
153
  "--undetected",
149
154
  action="store_true",
@@ -28,6 +28,7 @@ def run(
28
28
  remote=False,
29
29
  output_log=False,
30
30
  output_file=None,
31
+ use_cdp=False,
31
32
  undetected=False,
32
33
  optimize=False,
33
34
  use_proxy=False,
@@ -83,7 +84,7 @@ def run(
83
84
 
84
85
  run = create_pipeline_run(pipeline_id, variables, True)
85
86
  code = get_pipeline_code(
86
- program_name, variables, headless, undetected, optimize, use_proxy, pipeline_id=program_id
87
+ program_name, variables, headless, use_cdp, undetected, optimize, use_proxy, pipeline_id=program_id
87
88
  )["code"]
88
89
  start_time = datetime.datetime.now(datetime.timezone.utc).isoformat()
89
90
  run_data = {"start_time": start_time}
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: parsagon
3
- Version: 0.16.0
3
+ Version: 0.17.0
4
4
  Summary: Allows you to create browser automations with natural language
5
5
  Author-email: Sandy Suh <sandy@parsagon.io>
6
6
  Project-URL: Homepage, https://parsagon.io
@@ -8,15 +8,14 @@ Classifier: Programming Language :: Python :: 3
8
8
  Classifier: Operating System :: OS Independent
9
9
  Requires-Python: >=3.8
10
10
  Description-Content-Type: text/markdown
11
- Requires-Dist: seleniumbase==4.38.0
12
- Requires-Dist: selenium>=4.9.1
11
+ Requires-Dist: selenium==4.9.1
13
12
  Requires-Dist: lxml[html_clean]==5.3.2
14
13
  Requires-Dist: httpx>=0.27.0
15
14
  Requires-Dist: psutil==7.0.0
16
- Requires-Dist: rich>=13.6.0
15
+ Requires-Dist: rich==13.6.0
17
16
  Requires-Dist: PyVirtualDisplay==3.0
18
17
  Requires-Dist: selenium-wire==5.1.0
19
- Requires-Dist: cssselect>=1.2.0
18
+ Requires-Dist: cssselect==1.2.0
20
19
  Requires-Dist: undetected-chromedriver==3.5.5
21
20
  Requires-Dist: webdriver-manager==4.0.2
22
21
  Requires-Dist: jsonpath-ng==1.5.3
@@ -1,12 +1,11 @@
1
- seleniumbase==4.38.0
2
- selenium>=4.9.1
1
+ selenium==4.9.1
3
2
  lxml[html_clean]==5.3.2
4
3
  httpx>=0.27.0
5
4
  psutil==7.0.0
6
- rich>=13.6.0
5
+ rich==13.6.0
7
6
  PyVirtualDisplay==3.0
8
7
  selenium-wire==5.1.0
9
- cssselect>=1.2.0
8
+ cssselect==1.2.0
10
9
  undetected-chromedriver==3.5.5
11
10
  webdriver-manager==4.0.2
12
11
  jsonpath-ng==1.5.3
File without changes
File without changes
File without changes