BeautifulSoup Grab Visible Webpage Text

前端 未结 10 822
北恋
北恋 2020-11-22 07:35

Basically, I want to use BeautifulSoup to grab strictly the visible text on a webpage. For instance, this webpage is my test case. And I mainly want to just get the

10条回答
  •  借酒劲吻你
    2020-11-22 07:58

    Using BeautifulSoup the easiest way with less code to just get the strings, without empty lines and crap.

    tag = 
    soup = BeautifulSoup(tag, 'html.parser')
    
    for i in soup.stripped_strings:
        print repr(i)
    

提交回复
热议问题