[Python] Turn off BeautifulSoup messy encoding confidence output

Discussão em 'Python' iniciado por Stack, Abril 29, 2025.

  1. Stack

    Stack Membro Participativo

    I'm using bs4 for my project. It print out messy output with many encoding confidence score whenever I create a soup instance:

    req = urllib2.Request(url, headers=hdr)
    page = urllib2.urlopen(req, timeout=5)
    soup = BeautifulSoup(page.read(), "lxml")


    It works fine, but with redundant output. I just want to remove it, but I can't find any information about something like verbose option.

    2018-11-15 10:40:46,286 utf-8 confidence = 0.99
    2018-11-15 10:40:46,286 SHIFT_JIS Japanese confidence = 0.01
    2018-11-15 10:40:46,287 EUC-JP Japanese confidence = 0.01
    2018-11-15 10:40:46,287 GB2312 Chinese confidence = 0.01
    2018-11-15 10:40:46,287 EUC-KR Korean confidence = 0.01
    2018-11-15 10:40:46,287 CP949 Korean confidence = 0.01
    2018-11-15 10:40:46,287 Big5 Chinese confidence = 0.01
    2018-11-15 10:40:46,288 EUC-TW Taiwan confidence = 0.01
    2018-11-15 10:40:46,288 windows-1251 Russian confidence = 0.01
    2018-11-15 10:40:46,288 KOI8-R Russian confidence = 0.01
    2018-11-15 10:40:46,288 ISO-8859-5 Russian confidence = 0.0
    2018-11-15 10:40:46,288 MacCyrillic Russian confidence = 0.0
    2018-11-15 10:40:46,288 IBM866 Russian confidence = 0.0
    2018-11-15 10:40:46,289 IBM855 Russian confidence = 0.01
    2018-11-15 10:40:46,289 ISO-8859-7 Greek confidence = 0.0
    2018-11-15 10:40:46,289 windows-1253 Greek confidence = 0.0
    2018-11-15 10:40:46,289 ISO-8859-5 Bulgairan confidence = 0.0
    2018-11-15 10:40:46,289 windows-1251 Bulgarian confidence = 0.01
    2018-11-15 10:40:46,290 TIS-620 Thai confidence = 0.0
    2018-11-15 10:40:46,290 ISO-8859-9 Turkish confidence = 0.54363730033
    2018-11-15 10:40:46,290 windows-1255 Hebrew confidence = 0.0
    2018-11-15 10:40:46,290 windows-1255 Hebrew confidence = 0.0
    2018-11-15 10:40:46,290 windows-1255 Hebrew confidence = 0.0
    2018-11-15 10:40:46,291 utf-8 confidence = 0.99
    2018-11-15 10:40:46,291 SHIFT_JIS Japanese confidence = 0.01
    2018-11-15 10:40:46,291 EUC-JP Japanese confidence = 0.01
    2018-11-15 10:40:46,291 GB2312 Chinese confidence = 0.01
    2018-11-15 10:40:46,291 EUC-KR Korean confidence = 0.01
    2018-11-15 10:40:46,291 CP949 Korean confidence = 0.01
    2018-11-15 10:40:46,292 Big5 Chinese confidence = 0.01
    2018-11-15 10:40:46,292 EUC-TW Taiwan confidence = 0.01


    Please help. Any suggestion is gratefully appreciated!

    Continue reading...

Compartilhe esta Página