按照教程爬取猫眼电影,出现AttributeError: 'tuple' object has no attribute 'strip'错误
0
def parse_one_page(html):
pattern=re.compile(
'<dd>.*?board-index.*?>(\d+)</i>.*?<a.*?title="(.*?)".*?data-src="(.*?)".*?star">(.*?)</p>.*?releasetime">(.*?)</p>.*?integer">(.*?)</i>.*?fraction">(.*?)</i>.*?</dd>',
re.S)
items=re.findall(pattern, html)
for item in items:
yield {
'index': items[0],
'title': items[1],
'image': items[2],
[i][b] 'actor': items[3]
.strip()[3:],
[/b][/i]
'time': items[4],
'score': items[5] + items[6]
}
def main():
url='http://maoyan.com/board/4'
html=get_one_page(url)
for item in parse_one_page(html):
print(item)
没有找到相关结果
重要提示:提问者不能发表回复,可以通过评论与回答者沟通,沟通后可以通过编辑功能完善问题描述,以便后续其他人能够更容易理解问题.
0 个回复