python re

时间:2023-12-02 20:11:56

>>> url="http://apk.gfan.com/Product/App45021.html"
>>> result=html.content

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

NameError: name 'html' is not defined

>>> html=requests.get(url)

>>> result=html.content

>>> pattern=re.compile('版 本 号(.+?)</li>')

Traceback (most recent call last):

  File "<stdin>", line 1, in <module>

NameError: name 're' is not defined

>>> import re

>>> pattern=re.compile('版 本 号(.+?)</li>')

>>> data1=re.findall(pattern,result)

>>> print type(data1)

<type 'list'>

>>> print len(data1)

1

>>>