Easy way to get data between tags of xml or html files in python?

后端 未结 6 883
时光取名叫无心
时光取名叫无心 2021-02-06 17:05

I am using Python and need to find and retrieve all character data between tags:

I need this stuff

I then want to output

6条回答
  •  南笙
    南笙 (楼主)
    2021-02-06 17:22

    without external modules, eg

    >>> myhtml = """ I need this stuff
    ... blah blah
    ... I need this stuff too
    ... 
    ... blah blah """
    >>> for item in myhtml.split(""):
    ...   if "" in item:
    ...       print item [ item.find("")+len("") : ]
    ...
    I need this stuff
    I need this stuff too
    

提交回复
热议问题