Extracting text from HTML file using Python

后端 未结 30 2851
一生所求
一生所求 2020-11-22 04:05

I\'d like to extract the text from an HTML file using Python. I want essentially the same output I would get if I copied the text from a browser and pasted it into notepad.

30条回答
  •  面向向阳花
    2020-11-22 04:38

    you can extract only text from HTML with BeautifulSoup

    url = "https://www.geeksforgeeks.org/extracting-email-addresses-using-regular-expressions-python/"
    con = urlopen(url).read()
    soup = BeautifulSoup(con,'html.parser')
    texts = soup.get_text()
    print(texts)
    

提交回复
热议问题