在下面的示例中,我无法使用lib re获取数据,我做错了什么?
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import urllib
import re
def getData():
res=urllib.urlopen("http://www.quanshuwang.com/book/0/149/34333.html").read()
html = res.decode("gbk").encode("utf-8")
reg = r'style5\(\);</script>(.*?)<script type="text/javascript">style6'
print re.findall(reg,html)
getData()发布于 2017-07-20 21:56:21
你有
reg = r'style5\(\);</script>(.*?)<script type="text/javascript">style6'我认为你的问题是关于synthax的:
reg = 'style5\(\);</script>(.*?)<script type="text/javascript">style6'您必须删除多余的"r"
https://stackoverflow.com/questions/45210910
复制相似问题