我无法显示内容,我的程序:
#! /usr/bin/python
import urllib
import re
url = "http://yahoo.com"
pattern = '''<span class="medium item-label".*?>(.*)</span>'''
website = urllib.urlopen(url)
pageContent = website.read()
result = re.findall(pattern, pageContent)
for record in result:
print record
输出:
Masked teen killed by dad
First look in 'Hotel of Doom'
Ex-NFL QB's sad condition
Reporter ignores warning
Romney's low bar for debates
所以问题是我应该在我的代码中包含什么才能将 ' 转换为字符