parsagon 0.14.37__tar.gz → 0.14.39__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.14.37 → parsagon-0.14.39}/PKG-INFO +1 -1
  2. {parsagon-0.14.37 → parsagon-0.14.39}/pyproject.toml +1 -1
  3. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/api.py +4 -0
  4. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/executor.py +19 -0
  5. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/main.py +28 -4
  6. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon.egg-info/PKG-INFO +1 -1
  7. {parsagon-0.14.37 → parsagon-0.14.39}/README.md +0 -0
  8. {parsagon-0.14.37 → parsagon-0.14.39}/setup.cfg +0 -0
  9. {parsagon-0.14.37 → parsagon-0.14.39}/src/__init__.py +0 -0
  10. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/__init__.py +0 -0
  11. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/assistant.py +0 -0
  12. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/create.py +0 -0
  13. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/custom_function.py +0 -0
  14. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/edit.py +0 -0
  15. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/exceptions.py +0 -0
  16. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/gui/__init__.py +0 -0
  17. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/gui/controller.py +0 -0
  18. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/gui/menu.py +0 -0
  19. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/gui/window.py +0 -0
  20. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/gui_entry.py +0 -0
  21. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/highlights.js +0 -0
  22. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/print.py +0 -0
  23. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/runs.py +0 -0
  24. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/secrets.py +0 -0
  25. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/settings.py +0 -0
  26. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/tests/__init__.py +0 -0
  27. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/tests/api_mocks.py +0 -0
  28. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/tests/conftest.py +0 -0
  29. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/tests/test_executor.py +0 -0
  30. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/tests/test_invalid_args.py +0 -0
  31. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/tests/test_pipeline_operations.py +0 -0
  32. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/tests/test_print.py +0 -0
  33. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon/tests/test_secrets.py +0 -0
  34. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon.egg-info/SOURCES.txt +0 -0
  35. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon.egg-info/dependency_links.txt +0 -0
  36. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon.egg-info/entry_points.txt +0 -0
  37. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon.egg-info/requires.txt +0 -0
  38. {parsagon-0.14.37 → parsagon-0.14.39}/src/parsagon.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: parsagon
3
- Version: 0.14.37
3
+ Version: 0.14.39
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
@@ -16,7 +16,7 @@ line-length = 120
16
16
 
17
17
  [project]
18
18
  name = "parsagon"
19
- version = "0.14.37"
19
+ version = "0.14.39"
20
20
  description = "Allows you to create browser automations with natural language"
21
21
  readme = "README.md"
22
22
  requires-python = ">=3.8"
@@ -239,6 +239,10 @@ def get_pipeline(pipeline_name):
239
239
  )
240
240
 
241
241
 
242
+ def get_pipeline_by_id(pipeline_id):
243
+ return _api_call(httpx.get, f"/pipelines/{pipeline_id}/")
244
+
245
+
242
246
  def get_pipelines():
243
247
  return _api_call(httpx.get, f"/pipelines/")
244
248
 
@@ -1,3 +1,4 @@
1
+ import base64
1
2
  from collections import defaultdict
2
3
  import copy
3
4
  import dateutil.parser
@@ -11,8 +12,10 @@ import time
11
12
  from urllib.parse import urljoin
12
13
 
13
14
  import html2text
15
+ import httpx
14
16
  from lxml import etree
15
17
  import lxml.html
18
+ from lxml.html.clean import Cleaner
16
19
  from pypdf import PdfReader
17
20
  from pyvirtualdisplay import Display
18
21
  import undetected_chromedriver as uc
@@ -132,6 +135,7 @@ class Executor:
132
135
  self.execution_context = {
133
136
  "custom_assert": self.custom_assert,
134
137
  "goto": self.goto,
138
+ "goto_lite": self.goto_lite,
135
139
  "close_window": self.close_window,
136
140
  "click_elem": self.click_elem,
137
141
  "click_elem_by_id": self.click_elem_by_id,
@@ -380,6 +384,21 @@ class Executor:
380
384
 
381
385
  return self.driver.current_window_handle
382
386
 
387
+ def goto_lite(self, url, window_id=None):
388
+ if window_id in self.driver.window_handles:
389
+ self.driver.switch_to.window(window_id)
390
+ else:
391
+ self.driver.switch_to.new_window("tab")
392
+ # This is usually called in programs that use a proxy, but executor does not use proxies
393
+ with httpx.Client(verify=False) as client:
394
+ r = client.get(url, timeout=60)
395
+ cleaner = Cleaner()
396
+ cleaner.javascript = True
397
+ html = lxml.html.tostring(cleaner.clean_html(lxml.html.fromstring(r.text)))
398
+ self.driver.get("data:text/html;base64," + base64.b64encode(html).decode())
399
+ time.sleep(1)
400
+ return self.driver.current_window_handle
401
+
383
402
  def close_window(self, window_id):
384
403
  if self.driver.current_window_handle != window_id:
385
404
  self.driver.switch_to.window(window_id)
@@ -4,7 +4,14 @@ import logging.config
4
4
  import time
5
5
 
6
6
 
7
- from parsagon.api import delete_pipeline, add_examples_to_custom_function, get_pipeline, get_pipelines, poll_extract
7
+ from parsagon.api import (
8
+ delete_pipeline,
9
+ add_examples_to_custom_function,
10
+ get_pipeline,
11
+ get_pipeline_by_id,
12
+ get_pipelines,
13
+ poll_extract,
14
+ )
8
15
  from parsagon.assistant import assist
9
16
  from parsagon.api import delete_pipeline, add_examples_to_custom_function, get_pipeline, get_pipelines, poll_extract
10
17
  from parsagon.create import create_program
@@ -84,6 +91,11 @@ def get_args(argv):
84
91
  action="store_true",
85
92
  help="run the browser in headless mode",
86
93
  )
94
+ parser_update.add_argument(
95
+ "--undetected",
96
+ action="store_true",
97
+ help="run in undetected mode",
98
+ )
87
99
  parser_update.add_argument(
88
100
  "--infer",
89
101
  action="store_true",
@@ -208,17 +220,29 @@ def edit(program_name, variables={}, verbose=False):
208
220
  edit_program(task, program_name)
209
221
 
210
222
 
211
- def update(program_name, variables={}, headless=False, infer=False, replace=False, verbose=False):
223
+ def update(
224
+ program_name=None,
225
+ program_id=None,
226
+ variables={},
227
+ headless=False,
228
+ undetected=False,
229
+ infer=False,
230
+ replace=False,
231
+ verbose=False,
232
+ ):
212
233
  configure_logging(verbose)
213
234
 
214
- pipeline = get_pipeline(program_name)
235
+ if program_id:
236
+ pipeline = get_pipeline_by_id(program_id)
237
+ else:
238
+ pipeline = get_pipeline(program_name)
215
239
  abridged_program = pipeline["abridged_sketch"]
216
240
  # Make the program runnable
217
241
  variables_str = ", ".join(f"{k}={repr(v)}" for k, v in variables.items())
218
242
  abridged_program += f"\n\noutput = func({variables_str})\n"
219
243
 
220
244
  # Execute the abridged program to gather examples
221
- executor = Executor(pipeline["description"], headless=headless, infer=infer)
245
+ executor = Executor(pipeline["description"], headless=headless, infer=infer, use_uc=undetected)
222
246
  executor.execute(abridged_program)
223
247
 
224
248
  while True:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: parsagon
3
- Version: 0.14.37
3
+ Version: 0.14.39
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
File without changes
File without changes
File without changes