ValueError: Unicode strings with encoding declaration are not supported. Please use bytes input or XML fragments without declaration.

Đang mở
#142 5 bình luận 0 reaction 0 người được giao Xem trên GitHub

@AdrianAtZyte đang làm issue này rồi.

Từ ngày 27/9/2026.

  • #271 của @AdrianAtZyte — đang mở

Đá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
Loại issue
Lỗi
Độ rõ ràng
Cần làm rõ
Mức độ hoạt động
Đình trệ
Công nghệ
python
Lĩnh vực
web-dev

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

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của scrapinghub/extruct

Tất cả issue của scrapinghub/extruct

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.