我改变了脚本获取列表的方式,不知何故破坏了Gdata-API
sys.argv[1]为a text file of urls like this
当我注释掉Part 1和Part 2并添加3时,错误开始。当我删除3并取消Part 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就可以了。当文本文件增加到两个或更多项时,错误将被重现。
发布于 2011-12-08 05:23:46
我将urls指定为:
urls = ['http://www.youtube.com/watch?v=_wmD3M-BfVo'](是的,这是T-Pain音乐视频),它工作得很好。您很可能在打开的文件或该文件内容的解析方面存在问题。或者你只是没有正确地解析它。在任何情况下,您都会得到分配给none的注释,因为您没有传递有效的in。
https://stackoverflow.com/questions/8422302
复制相似问题