Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some encoding problem #1

Open
Hydrion-Qlz opened this issue Feb 1, 2023 · 1 comment
Open

Some encoding problem #1

Hydrion-Qlz opened this issue Feb 1, 2023 · 1 comment

Comments

@Hydrion-Qlz
Copy link

Hydrion-Qlz commented Feb 1, 2023

when test the homepage of the CSDN, it went wrong

python WPS_DB_Test.py https://www.csdn.net/

i got the log as follows:

Traceback (most recent call last):
  File "D:\TEMP\WebPage-Segmentation--WPS--main\WebPage-Segmentation--WPS--new\WPS_DB_Test.py", line 39, in <module>
    main()
  File "D:\TEMP\WebPage-Segmentation--WPS--main\WebPage-Segmentation--WPS--new\WPS_DB_Test.py", line 20, in main
    wpsdb = Wpsdb.Wpsdb(unquote(sys.argv[1], encoding="utf-8"))
  File "D:\TEMP\WebPage-Segmentation--WPS--main\WebPage-Segmentation--WPS--new\WPS_DB.py", line 36, in __init__
    self.getDomTree()
  File "D:\TEMP\WebPage-Segmentation--WPS--main\WebPage-Segmentation--WPS--new\WPS_DB.py", line 118, in getDomTree
    self.toHTMLFile(self.browser.page_source)
  File "D:\TEMP\WebPage-Segmentation--WPS--main\WebPage-Segmentation--WPS--new\WPS_DB.py", line 114, in toHTMLFile
    file.write(str(page_source))
UnicodeEncodeError: 'gbk' codec can't encode character '\xa9' in position 125149: illegal multibyte sequence

i'm not familar with the PR operation,so i just leave an issue

from the log it can be easily found that it's the encoding problem, i just add encoding='utf-8' and the problem has been solved, there are two places with this problem

  • ImageOut.py: line15
  • WPS_DB.py: line13
@Hydrion-Qlz
Copy link
Author

Hydrion-Qlz commented Feb 1, 2023

One more problem,beautifulsoup4 in requirements.txt has been misspelled

@Hydrion-Qlz Hydrion-Qlz changed the title 程序运行错误 Some encoding problem Feb 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant