BOM header

来源:互联网 发布:网络谣言研究报告 编辑:程序博客网 时间:2024/06/10 10:40

Today, I played with Bs4 package, It works nicely on the htmtl parsing.


I've always heard how troublesome it is about the encodes model in Python, and different versions. And I encoutered the stuff this afternoon. To be honest, it's really annoying...


Well, don't trouble trouble until touble troubles you.


As I installed the package, I tried to make something with the classes. But I got a problem with the input connection:


I tried many times in different ways, but it just did'n work. I changed the encode model, modified the module..


Since the notification says about the __int__.py, I even doubted that if I'd downloaded the damaged package, and redownload Bs4 again...


Still, It wasn't working. Later on, I noticed that it might has something to do with the html mark file. And that's exactly where the problem at!


Beacause I copy the text from the Internet in a txt file, and rename it into a html. The windows make it in UTF-8 with BOM... And that causes all the troubles.


After I convert the html file into a UTF-8 without BOM encode with Nodepad++. It started to work.



This gives me a lesson, I should've turn to the official docments about Bs4 in the first place. Lots of docs on the Internet misinterpretered the docs...