【发布时间】:2011-12-07 20:46:43
【问题描述】:
我更改了脚本获取列表的方式,但不知何故我破坏了 Gdata-API
sys.argv[1] 是a text file of urls like this
当我注释掉第 1 部分和第 2 部分并添加 3 时,错误开始。当我删除 3 并取消注释第 1 部分和第 2 部分时,它再次起作用。
相关代码:
# PART 1 - parse bookmarks.html
#with open(sys.argv[1]) as bookmark_file:
# soup = BeautifulSoup(bookmark_file.read())
# PART 2 - extract youtube video urls
#video_url_regex = re.compile('http://www.youtube.com/watch')
#urls = [link['href'] for link in soup('a', href=video_url_regex)]
# PART 3 - parse text file
urls = open(sys.argv[1]).readlines()
我现在得到的错误:
Traceback (most recent call last):
File "listtest.py", line 81, in <module>
comments = comments.total_results.text
AttributeError: 'NoneType' object has no attribute 'total_results'
我想继续获取“总评论数”字段。谢谢。
完整代码: http://pastebin.com/1yZdEySW
编辑:文本文件中的一个 URL 很好。当文本文件增加到两个或更多项时,就会重现错误。
【问题讨论】:
标签: python youtube youtube-api