scrape-cli 1.3.4__tar.gz → 1.3.5__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.
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/PKG-INFO +3 -1
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/pyproject.toml +4 -1
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/scrape_cli/__init__.py +1 -1
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/scrape_cli/scrape.py +7 -3
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/scrape_cli.egg-info/PKG-INFO +3 -1
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/scrape_cli.egg-info/requires.txt +3 -0
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/tests/test_scrape.py +20 -0
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/README.md +0 -0
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/scrape_cli.egg-info/SOURCES.txt +0 -0
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/scrape_cli.egg-info/dependency_links.txt +0 -0
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/scrape_cli.egg-info/entry_points.txt +0 -0
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/scrape_cli.egg-info/top_level.txt +0 -0
- {scrape_cli-1.3.4 → scrape_cli-1.3.5}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scrape_cli
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.5
|
|
4
4
|
Summary: It's a command-line tool to extract HTML elements using an XPath query or CSS3 selector.
|
|
5
5
|
Author-email: Andrea Borruso <aborruso@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/aborruso/scrape-cli
|
|
@@ -12,6 +12,8 @@ Requires-Dist: cssselect
|
|
|
12
12
|
Requires-Dist: lxml
|
|
13
13
|
Requires-Dist: requests
|
|
14
14
|
Requires-Dist: xmltodict
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pytest; extra == "dev"
|
|
15
17
|
|
|
16
18
|
[](https://pypi.org/project/scrape-cli/)
|
|
17
19
|
[](https://pypi.org/project/scrape-cli/)
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "scrape_cli"
|
|
7
|
-
version = "1.3.
|
|
7
|
+
version = "1.3.5"
|
|
8
8
|
description = "It's a command-line tool to extract HTML elements using an XPath query or CSS3 selector."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
authors = [
|
|
@@ -22,6 +22,9 @@ dependencies = [
|
|
|
22
22
|
"xmltodict"
|
|
23
23
|
]
|
|
24
24
|
|
|
25
|
+
[project.optional-dependencies]
|
|
26
|
+
dev = ["pytest"]
|
|
27
|
+
|
|
25
28
|
[project.urls]
|
|
26
29
|
Homepage = "https://github.com/aborruso/scrape-cli"
|
|
27
30
|
|
|
@@ -162,8 +162,8 @@ notes:
|
|
|
162
162
|
- -j fails with exit 1 on attribute names that are not valid XML, such as
|
|
163
163
|
@click or :bind. Use -e without -j on those pages.
|
|
164
164
|
- URLs: 30 s timeout, HTTP errors (4xx, 5xx) exit 1.
|
|
165
|
-
- Charset: from the meta tag, otherwise UTF-8
|
|
166
|
-
|
|
165
|
+
- Charset: from the meta tag, otherwise UTF-8. If the bytes are not valid
|
|
166
|
+
UTF-8: Windows-1252, then ISO-8859-1. Other encodings need the meta tag.
|
|
167
167
|
'''
|
|
168
168
|
)
|
|
169
169
|
|
|
@@ -307,7 +307,11 @@ notes:
|
|
|
307
307
|
try:
|
|
308
308
|
inp.decode('utf-8')
|
|
309
309
|
except UnicodeDecodeError:
|
|
310
|
-
|
|
310
|
+
# cp1252 rejects five undefined bytes, iso-8859-1 accepts them all
|
|
311
|
+
try:
|
|
312
|
+
inp = inp.decode('cp1252').encode('utf-8')
|
|
313
|
+
except UnicodeDecodeError:
|
|
314
|
+
inp = inp.decode('iso-8859-1').encode('utf-8')
|
|
311
315
|
document = etree.fromstring(inp, html_parser)
|
|
312
316
|
except (etree.XMLSyntaxError, UnicodeDecodeError) as e:
|
|
313
317
|
# Print an error in case of syntax issues in the HTML
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: scrape_cli
|
|
3
|
-
Version: 1.3.
|
|
3
|
+
Version: 1.3.5
|
|
4
4
|
Summary: It's a command-line tool to extract HTML elements using an XPath query or CSS3 selector.
|
|
5
5
|
Author-email: Andrea Borruso <aborruso@gmail.com>
|
|
6
6
|
Project-URL: Homepage, https://github.com/aborruso/scrape-cli
|
|
@@ -12,6 +12,8 @@ Requires-Dist: cssselect
|
|
|
12
12
|
Requires-Dist: lxml
|
|
13
13
|
Requires-Dist: requests
|
|
14
14
|
Requires-Dist: xmltodict
|
|
15
|
+
Provides-Extra: dev
|
|
16
|
+
Requires-Dist: pytest; extra == "dev"
|
|
15
17
|
|
|
16
18
|
[](https://pypi.org/project/scrape-cli/)
|
|
17
19
|
[](https://pypi.org/project/scrape-cli/)
|
|
@@ -117,6 +117,26 @@ def test_encoding_falls_back_to_iso_8859_1_without_meta(tmp_path):
|
|
|
117
117
|
assert result.stdout == "Caffè\n"
|
|
118
118
|
|
|
119
119
|
|
|
120
|
+
def test_encoding_windows_1252_without_meta(tmp_path):
|
|
121
|
+
html_file = tmp_path / "cp1252.html"
|
|
122
|
+
html_file.write_bytes("<h1>Caffè € ’</h1>".encode("cp1252"))
|
|
123
|
+
|
|
124
|
+
result = run_scrape(str(html_file), "-e", "string(//h1)")
|
|
125
|
+
|
|
126
|
+
assert result.returncode == 0
|
|
127
|
+
assert result.stdout == "Caffè € ’\n"
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
def test_encoding_bytes_undefined_in_windows_1252_fall_back_to_iso_8859_1(tmp_path):
|
|
131
|
+
html_file = tmp_path / "undefined.html"
|
|
132
|
+
html_file.write_bytes(b"<h1>Caff\xe8 \x81</h1>")
|
|
133
|
+
|
|
134
|
+
result = run_scrape(str(html_file), "-e", "string(//h1)")
|
|
135
|
+
|
|
136
|
+
assert result.returncode == 0
|
|
137
|
+
assert result.stdout.startswith("Caffè")
|
|
138
|
+
|
|
139
|
+
|
|
120
140
|
def test_encoding_utf8_without_meta_is_not_converted(tmp_path):
|
|
121
141
|
html_file = tmp_path / "utf8.html"
|
|
122
142
|
html_file.write_bytes("<h1>Caffè €</h1>".encode("utf-8"))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|