What does the br.set_handle_gzip mechanized tag do?

I am trying to use the python mechanization module to write some scripts. When I run it I get the following error. Is it actually 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?

+1


source to share


1 answer


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

br.set_handle_gzip(True)

      

To remove the warning message, change True

to False

.



As far as the error message goes, this is because your script cannot find a link that reads "Exit" on the page you are working with.

br.follow_link(text='Sign out') 

      

Change the value of the text on this line to the same value as on the page. This will solve your problem.

+1


source







All Articles