ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 30/100
Hướng nghiên cứu
Start by tracing extruct.extract in extruct/_extruct.py into parse_xmldom_html in extruct/utils.py, then reproduce the failure with the URL and input shown in the report. Clarify the project's expected handling of lxml parsing errors before defining a regression test and the intended graceful behavior.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
When scraping the URL: http://www.reakes.com/
Error:
Traceback (most recent call last):
File ".../website_scraping.py", line 161, in getWebsiteScrapedDataForURL
data = extruct.extract(r.text, base_url=base_url)
File "/usr/local/lib/python3.8/site-packages/extruct/_extruct.py", line 58, in extract
tree = parse_xmldom_html(htmlstring, encoding=encoding)
File "/usr/local/lib/python3.8/site-packages/extruct/utils.py", line 16, in parse_xmldom_html
return lxml.html.fromstring(html, parser=parser)
File "/usr/local/lib/python3.8/site-packages/lxml/html/__init__.py", line 875, in fromstring
doc = document_fromstring(html, parser=parser, base_url=base_url, **kw)
File "/usr/local/lib/python3.8/site-packages/lxml/html/__init__.py", line 761, in document_fromstring
value = etree.fromstring(html, parser, **kw)
File "src/lxml/etree.pyx", line 3237, in lxml.etree.fromstring
File "src/lxml/parser.pxi", line 1871, in lxml.etree._parseMemoryDocument
ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.
I would expect a scraper to fail gracefully and not let a problem with lxml propagate out, but not sure what the philosophy of extruct is specifically.
This might be helpful:
https://stackoverflow.com/questions/15830421/xml-unicode-strings-with-encoding-declaration-are-not-supported
- Ngôn ngữ chính
- Python
- Star
- 986
- Fork
- 127
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của scrapinghub/extruct
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 45/100
scrapinghub/extruct#278 · 1 reaction ·
-
Migrate to pytestCó thể đã có người làm @Rotzbua đã nhận 135 ngày trước. Đang mở
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
scrapinghub/extruct#252 ·
-
Tests fail with windowsCó thể đã có người làm @Rotzbua đã nhận 136 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 45/100
scrapinghub/extruct#251 ·
-
Install on modern pip and setuptools is failingCó thể đã có người làm @Rotzbua đã nhận 163 ngày trước. Đang mở
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 35/100
scrapinghub/extruct#241 · 5 bình luận ·
-
Fix the Build Status badgeCó thể đã có người làm @Rotzbua đã nhận 163 ngày trước. Đang mởbug docs
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 56/100
scrapinghub/extruct#236 ·
Tất cả issue của scrapinghub/extruct
Issue tương tự
-
[19.0] pos_sale: settling an order with a 0 down payment line crashes (reading 'reward_id') and leaves a wrong amount dueCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 79/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 79/100
developmentseed/titiler-covjson#164 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 82/100
awslabs/visual-asset-management-system#2164 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
needs-triage
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
MakazhanAlpamys/Soup#3589 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
channels status reports the wrong Enabled value for Feishu instances and default-enabled WebSocketĐang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
Maintainer thường phản hồi trong vòng 1 ngày