0
from bs4 import BeautifulSoup
soup = BeautifulSoup(open("index.html"))
soup = BeautifulSoup(""<html>data</html>"")

Getting this warning: BeautifulSoup([your markup]) to this: BeautifulSoup([your markup], "lxml") markup_type=markup_type))

1 Answers1

0

BeautifulSoup need to know what to parse The thing you are giving maybe html, maybe xml, both have somewhat different structures So in the second argument of the function you need to specify that whether the given document is html/xml or whatever

from bs4 import BeautifulSoup
src='"<html>data<//html>"'
soup=BeautifulSoup(src,"html.parser")
ibadia
  • 909
  • 6
  • 15
  • 1
    Whilst this code snippet is welcome, and may provide some help, it would be [greatly improved if it included an explanation](//meta.stackexchange.com/q/114762) of *how* it addresses the question. Without that, your answer has much less educational value - remember that you are answering the question for readers in the future, not just the person asking now! Please [edit] your answer to add explanation, and give an indication of what limitations and assumptions apply. – Toby Speight May 01 '17 at 12:26
  • sir still getting that error. –  May 01 '17 at 12:27
  • can you explain your error? – ibadia May 01 '17 at 12:39
  • Resolved by adding the type of document I want to parse as the second argument in the **BeautifulSoup()** function. Thanks to all for helping. –  Dec 14 '18 at 03:45