我在一段时间内遇到了这个基本问题,但不确定问题是什么。我在运行以下代码时收到的错误是:
AttributeError: 'list' object has no attribute 'find'
这是代码:
import xml.etree.ElementTree as ET
import requests
r = requests.get('http://www.11alive.com/rss/local/3/10.xml')
root = ET.fromstring(r.text.encode('utf-8'))
channel = root.find('channel')
items = channel.findall('item')
news = []
for i in range(3):
news.append(items.find('title').text)
news.append(items.find('link').text)
print news