lambda-playwright 0.1.2__py3-none-any.whl → 0.1.4__py3-none-any.whl

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.
@@ -2,7 +2,7 @@ import os
2
2
  import json
3
3
  import logging
4
4
  import requests
5
- from typing import Optional, Dict, Union, Any
5
+ from typing import Optional, Dict, Any
6
6
  from requests_aws4auth import AWS4Auth
7
7
  from .types import Endpoint, VisitPagePayload, RenderHtmlPayload
8
8
 
@@ -19,7 +19,7 @@ class LambdaPlaywright:
19
19
  function_url: Optional[str] = None,
20
20
  access_key_id: Optional[str] = None,
21
21
  secret_access_key: Optional[str] = None,
22
- region: str = "ap-southeast-1",
22
+ region: str = "ap-southeast-2",
23
23
  debug: bool = False,
24
24
  local_url: str = "http://localhost:9000/2015-03-31/functions/function/invocations",
25
25
  ):
@@ -30,7 +30,7 @@ class LambdaPlaywright:
30
30
  function_url: The AWS Lambda Function URL. Defaults to AWS_PLAYWRIGHT_FUNCTION_URL env var.
31
31
  access_key_id: AWS Access Key ID. Defaults to AWS_PLAYWRIGHT_ACCESS_KEY env var.
32
32
  secret_access_key: AWS Secret Access Key. Defaults to AWS_PLAYWRIGHT_SECRET_ACCESS env var.
33
- region: AWS Region. Defaults to "ap-southeast-1".
33
+ region: AWS Region. Defaults to "ap-southeast-2".
34
34
  debug: If True, invoke local Lambda container. Defaults to False.
35
35
  local_url: URL for local Lambda container. Defaults to standard RIE URL.
36
36
  """
@@ -0,0 +1,179 @@
1
+ Metadata-Version: 2.4
2
+ Name: lambda_playwright
3
+ Version: 0.1.4
4
+ Summary: SDK for invoking Lambda Playwright service
5
+ Author: Hubexo
6
+ Requires-Python: >=3.8
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: requests>=2.25.0
9
+ Requires-Dist: requests-aws4auth>=1.1.0
10
+ Dynamic: author
11
+ Dynamic: description
12
+ Dynamic: description-content-type
13
+ Dynamic: requires-dist
14
+ Dynamic: requires-python
15
+ Dynamic: summary
16
+
17
+ # Lambda Playwright SDK
18
+
19
+ A Python SDK for interacting with the Lambda Playwright service.
20
+
21
+ ## Installation
22
+
23
+ ```bash
24
+ pip install lambda-playwright
25
+ ```
26
+
27
+ ## Usage
28
+
29
+ ### Initialization
30
+
31
+ ```python
32
+ from lambda_playwright import LambdaPlaywright
33
+
34
+ # Initialize with environment variables (AWS_PLAYWRIGHT_FUNCTION_URL, AWS_PLAYWRIGHT_ACCESS_KEY, AWS_PLAYWRIGHT_SECRET_ACCESS)
35
+ client = LambdaPlaywright()
36
+
37
+ # Or explicitly
38
+ client = LambdaPlaywright(
39
+ function_url="https://your-function-url.lambda-url.ap-southeast-1.on.aws",
40
+ access_key_id="your-access-key-id",
41
+ secret_access_key="your-secret-access-key",
42
+ region="ap-southeast-2"
43
+ )
44
+ ```
45
+
46
+ ### Visit a Page
47
+
48
+ ```python
49
+ response = client.visit({
50
+ "url": "https://example.com",
51
+ "actions": [
52
+ {"type": "wait_for_selector", "selector": "a"}
53
+ ],
54
+ })
55
+
56
+ print(response["html"])
57
+ ```
58
+
59
+ ### Render HTML
60
+
61
+ ```python
62
+ response = client.render_html({
63
+ "html_content": "<h1>Hello World</h1><script>document.write('Loaded');</script>",
64
+ "actions": [],
65
+ "scroll_to_bottom": True
66
+ })
67
+
68
+ print(response["html"])
69
+ ```
70
+
71
+ ## Development
72
+
73
+ To run locally against a local Lambda container:
74
+
75
+ ```python
76
+ client = LambdaPlaywright(debug=True)
77
+ ```
78
+
79
+ ## Available Actions
80
+
81
+ You can pass a list of actions to be executed on the page.
82
+
83
+ ### `click`
84
+ Clicks on an element matching the selector.
85
+ ```python
86
+ {"type": "click", "selector": "button#submit"}
87
+ ```
88
+
89
+ ### `wait_for_selector`
90
+ Waits for an element to appear in the DOM.
91
+ - `timeout` (optional): Maximum time to wait in milliseconds (default: 10000).
92
+ ```python
93
+ {"type": "wait_for_selector", "selector": ".content", "timeout": 5000}
94
+ ```
95
+
96
+ ### `sleep`
97
+ Pauses execution for a specified duration.
98
+ ```python
99
+ {"type": "sleep", "duration": 2.5} # Sleep for 2.5 seconds
100
+ ```
101
+
102
+ ### `scroll_to_bottom`
103
+ Scrolls to the bottom of the page to load dynamic content.
104
+ ```python
105
+ {"type": "scroll_to_bottom"}
106
+ ```
107
+
108
+ ### `fill`
109
+ Fills a form input field.
110
+ ```python
111
+ {"type": "fill", "selector": "input[name='q']", "value": "search term"}
112
+ ```
113
+
114
+ ### `type`
115
+ Types text into an input field, with optional delay between key presses.
116
+ ```python
117
+ {"type": "type", "selector": "#notes", "text": "Hello", "delay": 100}
118
+ ```
119
+
120
+ ### `evaluate`
121
+ Executes custom JavaScript in the browser context.
122
+ ```python
123
+ {"type": "evaluate", "script": "document.body.style.backgroundColor = 'red'"}
124
+ ```
125
+
126
+ ## Payload Reference
127
+
128
+ ### Visit Page Payload (`client.visit`)
129
+
130
+ | Field | Type | Description |
131
+ |-------|------|-------------|
132
+ | `url` | `str` | **Required**. The URL to visit. |
133
+ | `actions` | `List[Action]` | List of actions to perform. |
134
+ | `headers` | `dict` | Custom HTTP headers. |
135
+ | `cookies` | `dict` | Cookies to set. |
136
+ | `user_agent` | `str` | Custom User-Agent string. |
137
+ | `max_retries` | `int` | Number of retries on failure (default: 3). |
138
+ | `timeout_ms` | `int` | Global timeout in milliseconds (default: 60000). |
139
+ | `wait_for_network_idle` | `bool` | Wait for network to be idle (default: True). |
140
+ | `scroll_to_bottom` | `bool` | Automatically scroll to bottom (default: True). |
141
+
142
+ ### Render HTML Payload (`client.render_html`)
143
+
144
+ | Field | Type | Description |
145
+ |-------|------|-------------|
146
+ | `html_content` | `str` | **Required**. The HTML content to render. |
147
+ | `actions` | `List[Action]` | List of actions to perform. |
148
+ | `max_retries` | `int` | Number of retries on failure (default: 3). |
149
+ | `timeout_ms` | `int` | Global timeout in milliseconds (default: 60000). |
150
+ | `wait_for_network_idle` | `bool` | Wait for network to be idle (default: True). |
151
+ | `scroll_to_bottom` | `bool` | Automatically scroll to bottom (default: False). |
152
+
153
+ ## Publishing to PyPI
154
+
155
+ To publish a new version of the SDK to PyPI:
156
+
157
+ 1. **Update Version**: Increment the version number in `setup.py`.
158
+ ```python
159
+ setup(
160
+ # ...
161
+ version="0.1.x",
162
+ # ...
163
+ )
164
+ ```
165
+
166
+ 2. **Clean Builds**: Remove previous build artifacts.
167
+ ```bash
168
+ rm -rf dist build *.egg-info
169
+ ```
170
+
171
+ 3. **Build Package**: Create source and wheel distributions.
172
+ ```bash
173
+ python3 setup.py sdist bdist_wheel
174
+ ```
175
+
176
+ 4. **Upload**: Upload the new version to PyPI using `twine`.
177
+ ```bash
178
+ twine upload dist/*
179
+ ```
@@ -0,0 +1,7 @@
1
+ lambda_playwright/__init__.py,sha256=wM-jJdR5xKphtiKLfXhKzkk0Njp2GBZRcD5DjfJyajg,236
2
+ lambda_playwright/client.py,sha256=kUOaGxmNc41e1y0y_SX4ehb7fMGXWhAzG6K5vORMr24,5324
3
+ lambda_playwright/types.py,sha256=FA8GZTgE01-eq0mVRHPjDIlTkcol61PB1-W-QTUssbo,1198
4
+ lambda_playwright-0.1.4.dist-info/METADATA,sha256=AF-1p9ncKsI-mC9-C9tIx-TOhdUCBUdqhf4PvcBhPBQ,4541
5
+ lambda_playwright-0.1.4.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
+ lambda_playwright-0.1.4.dist-info/top_level.txt,sha256=80BqofT54Wl3SPgeA9kUVxj4yytBtZ3qLsPt5svzK7w,18
7
+ lambda_playwright-0.1.4.dist-info/RECORD,,
@@ -1,77 +0,0 @@
1
- Metadata-Version: 2.4
2
- Name: lambda_playwright
3
- Version: 0.1.2
4
- Summary: SDK for invoking Lambda Playwright service
5
- Author: Hubexo
6
- Requires-Python: >=3.8
7
- Description-Content-Type: text/markdown
8
- Requires-Dist: requests>=2.25.0
9
- Requires-Dist: requests-aws4auth>=1.1.0
10
- Dynamic: author
11
- Dynamic: description
12
- Dynamic: description-content-type
13
- Dynamic: requires-dist
14
- Dynamic: requires-python
15
- Dynamic: summary
16
-
17
- # Lambda Playwright SDK
18
-
19
- A Python SDK for interacting with the Lambda Playwright service.
20
-
21
- ## Installation
22
-
23
- ```bash
24
- pip install lambda-playwright
25
- ```
26
-
27
- ## Usage
28
-
29
- ### Initialization
30
-
31
- ```python
32
- from lambda_playwright import LambdaPlaywright
33
-
34
- # Initialize with environment variables (AWS_PLAYWRIGHT_FUNCTION_URL, AWS_PLAYWRIGHT_ACCESS_KEY, AWS_PLAYWRIGHT_SECRET_ACCESS)
35
- client = LambdaPlaywright()
36
-
37
- # Or explicitly
38
- client = LambdaPlaywright(
39
- function_url="https://your-function-url.lambda-url.ap-southeast-1.on.aws",
40
- access_key_id="your-access-key-id",
41
- secret_access_key="your-secret-access-key",
42
- region="ap-southeast-2"
43
- )
44
- ```
45
-
46
- ### Visit a Page
47
-
48
- ```python
49
- response = client.visit({
50
- "url": "https://example.com",
51
- "actions": [
52
- {"type": "wait_for_selector", "selector": "a"}
53
- ],
54
- })
55
-
56
- print(response["html"])
57
- ```
58
-
59
- ### Render HTML
60
-
61
- ```python
62
- response = client.render_html({
63
- "html_content": "<h1>Hello World</h1><script>document.write('Loaded');</script>",
64
- "actions": [],
65
- "scroll_to_bottom": True
66
- })
67
-
68
- print(response["html"])
69
- ```
70
-
71
- ## Development
72
-
73
- To run locally against a local Lambda container:
74
-
75
- ```python
76
- client = LambdaPlaywright(debug=True)
77
- ```
@@ -1,7 +0,0 @@
1
- lambda_playwright/__init__.py,sha256=wM-jJdR5xKphtiKLfXhKzkk0Njp2GBZRcD5DjfJyajg,236
2
- lambda_playwright/client.py,sha256=uXDtzeV_x81H3vvkB1xt-QLJ_biolVYl9sobfMdVoGw,5331
3
- lambda_playwright/types.py,sha256=FA8GZTgE01-eq0mVRHPjDIlTkcol61PB1-W-QTUssbo,1198
4
- lambda_playwright-0.1.2.dist-info/METADATA,sha256=sxVUrlLo9ke27KKrkvGY6oVjMziKA-ZVWMbqspoemgI,1584
5
- lambda_playwright-0.1.2.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
6
- lambda_playwright-0.1.2.dist-info/top_level.txt,sha256=80BqofT54Wl3SPgeA9kUVxj4yytBtZ3qLsPt5svzK7w,18
7
- lambda_playwright-0.1.2.dist-info/RECORD,,