机械化标签br.set_handle_gzip会做什么? [英] what does mechanize tag br.set_handle_gzip do?

查看:60
本文介绍了机械化标签br.set_handle_gzip会做什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用python机械化模块以编写一些脚本. 当我运行它时,出现以下错误.set_handle_gzip实际上是什么?

I'm trying python mechanize module in order to write some scripts. When i run it i get the following error.What actually is this set_handle_gzip ?

manoj@ubuntu:~/pyth$ python rock.py                                    │                                                                      
rock.py:15: UserWarning: gzip transfer encoding is experimental!       │                                                                      
  br.set_handle_gzip(True)                                             │                                                                      
Traceback (most recent call last):                                     │                                                                      
  File "rock.py", line 60, in <module>                                 │                                                                      
    br.follow_link(text='Sign out')                                    │                                                                      
  File "/usr/lib/python2.7/dist-packages/mechanize/_mechanize.py", line│                                                                      
 569, in follow_link                                                   │                                                                      
    return self.open(self.click_link(link, **kwds))                    │                                                                      
  File "/usr/lib/python2.7/dist-packages/mechanize/_mechanize.py", line│                                                                      
 553, in click_link                                                    │                                                                      
    link = self.find_link(**kwds)                                      │                                                                      
  File "/usr/lib/python2.7/dist-packages/mechanize/_mechanize.py", line│                                                                      
 620, in find_link                         
    raise LinkNotFoundError()                                          │                                                                      
mechanize._mechanize.LinkNotFoundError 

我该如何克服这个错误?

and how can i overcome this error?

推荐答案

由于以下原因,生成了gzip传输编码警告:

The gzip transfer encoding warning is generated because of the following line:

br.set_handle_gzip(True)

要删除警告消息,请将True更改为False.

To remove the warning message, change True to False.

对于错误消息,这是因为您的脚本无法在您正在使用的页面上找到显示退出"的链接.

As for the error message, it is because your script is unable to find a link that reads 'Sign out' on the page that you're working with.

br.follow_link(text='Sign out') 

将此行中的文本值更改为与页面上使用的值相同.这样可以解决您的问题.

Change the value of text in this line to the same value as is used on the page. That will solve your problem.

这篇关于机械化标签br.set_handle_gzip会做什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆