简体   繁体   English

如何解析来自RSS供稿的编码数据?

[英]How to parse encoding data from the rss feed?

我正在解析rss feed。但是我可以解析来自rss feed的编码数据。如何解析来自rss feed的编码数据?

It's a rough task. 这是一项艰巨的任务。 feedparser (Python) does a number of things to try to appropriately guess the right character set. feedparser (Python)做了很多事情来尝试适当地猜测正确的字符集。 There are a few places where it can be provided -- such as the header of the XML and the header from the HTTP transaction (which overrides the header of the XML). 可以在几个地方提供它-例如XML的标头和HTTP事务的标头(覆盖XML的标头)。 If it's not there (or it's completely invalid which is quite common), it falls back to statistical guessing. 如果它不存在(或者完全无效,这很普遍),则可以依靠统计猜测。 There's one last technique -- try converting it as UTF-8 and if that fails, convert it from ISO-8859-1 to UTF-8 and try again. 最后一种技术-尝试将其转换为UTF-8,如果失败,则将其从ISO-8859-1转换为UTF-8,然后重试。 Good luck! 祝好运!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM