为什么我在使用 IMDbPY 时收到这么多警告和一些错误?

发布于 2024-10-24 08:46:36 字数 2889 浏览 0 评论 0原文

我正在使用 IMDbPY 从 IMDb 检索数据。我得到了正确的结果,一切看起来都很好,除了一件事:无论我做什么,我都会收到警告。结果很好,但只有在一长串警告和有时是错误之后才会出现。

例如:下面的代码应该打印 Resevior Dogs (1992):

import imdb
db = imdb.IMDb()
movie_obj = db.search_movie('pulp fiction')[0]
db.update(movie_obj)
print movie_obj['long imdb canonical title']

它确实这样做了,但在出现以下警告和错误之前不会:

2011-03-18 00:33:11,490 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:11,507 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:13,483 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:13,483 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:15,137 ERROR [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:566: DOMHTMLMovieParser: caught exception extracting XPath "//div[@id='tn15title']//span[starts-with(text(), 'TV series')]"
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\imdb\parser\http\utils.py", line 555, in xpath
    xpath_result = element.xpath(path)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\etree.py", line 57, in xpath
    return path.apply(node)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 113, in apply
    nodes = step.apply(nodes)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 287, in apply
    found = filter(checker, found)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 331, in __call__
    return self.__filter(node)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 360, in __starts_with
    first = node.contents[0]
IndexError: list index out of range
2011-03-18 00:33:16,785 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:16,785 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:16,849 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:16,849 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"

为什么我会得到这个?我做错了什么吗?

I'm using IMDbPY to retrieve data from IMDb. I'm getting the right results and everything looks OK except one thing: No matter what I do, I get warnings. The results are fine, but they appear only after a long list of warnings and sometimes errors.

For example: The following code is supposed to print Resevior Dogs (1992):

import imdb
db = imdb.IMDb()
movie_obj = db.search_movie('pulp fiction')[0]
db.update(movie_obj)
print movie_obj['long imdb canonical title']

It does so, but not before the following warnings and error:

2011-03-18 00:33:11,490 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:11,507 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:13,483 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:13,483 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:15,137 ERROR [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:566: DOMHTMLMovieParser: caught exception extracting XPath "//div[@id='tn15title']//span[starts-with(text(), 'TV series')]"
Traceback (most recent call last):
  File "C:\Python27\lib\site-packages\imdb\parser\http\utils.py", line 555, in xpath
    xpath_result = element.xpath(path)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\etree.py", line 57, in xpath
    return path.apply(node)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 113, in apply
    nodes = step.apply(nodes)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 287, in apply
    found = filter(checker, found)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 331, in __call__
    return self.__filter(node)
  File "C:\Python27\lib\site-packages\imdb\parser\http\bsouplxml\bsoupxpath.py", line 360, in __starts_with
    first = node.contents[0]
IndexError: list index out of range
2011-03-18 00:33:16,785 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:16,785 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"
2011-03-18 00:33:16,849 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:459: unable to use "lxml": No module named lxml.html
2011-03-18 00:33:16,849 WARNING [imdbpy.parser.http.domparser] C:\Python27\lib\site-packages\imdb\parser\http\utils.py:450: falling back to "beautifulsoup"

Why do I get this? Am I doing something wrong?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等你爱我 2024-10-31 08:46:36

嗯,这是非常不言自明的:

无法使用“lxml”:没有名为 lxml.html 的模块

您可以执行此操作来检查该模块是否存在吗?

  1. 在终端或命令提示符中,运行 python
  2. 发布第一行的输出(例如 Python 2.6.6 (r266...)。
  3. 在 shell 中,输入 import lxml
  4. 接下来,尝试 import lxml.html

对我来说,发生的情况是这样的:

blender@desktop:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> import lxml.html
>>> 

我安装了模块,所以我没有得到任何输出(它导入成功)。

Well, this is pretty self-explanatory:

unable to use "lxml": No module named lxml.html

Can you do this to check if the module exists?

  1. In Terminal or Command Prompt, run python.
  2. Post the output of the first line (e.g. Python 2.6.6 (r266...).
  3. In the shell, type in import lxml.
  4. Next, try import lxml.html.

For me, this is what happens:

blender@desktop:~$ python
Python 2.6.6 (r266:84292, Sep 15 2010, 16:22:56) 
[GCC 4.4.5] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import lxml
>>> import lxml.html
>>> 

I have the module installed, so I don't get any output (it imported successfully).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文