mechanize

Set Mechanize to accept cookies

我只是一个虾纸丫 提交于 2019-12-24 05:16:26
问题 I am trying to use mechanize to retrieve some data from a website to automatize searching for a flat (no spamming) However, when I send a request to the site, the response has the following headers: header: Cache-Control: no-store, no-cache, max-age=0, must-revalidate, private, max- stale=0, post-check=0, pre-check=0 header: Content-Type: text/html header: P3P: CP="ALL IND DSP COR ADM CONo CUR CUSo IVAo IVDo PSA PSD TAI TELo OUR SAMo CNT COM INT NAV ONL PHY PRE PUR UNI" header: Date: Mon, 16

Python mechanize login Facebook, use beautifulshoup get profile picture failed

不羁岁月 提交于 2019-12-24 03:53:32
问题 I'm trying to keep login Facebook using Python mechanize library and get Zuck's profile picture url using BeautifulSoup. Here is my code: import cookielib import mechanize from BeautifulSoup import BeautifulSoup # Browser br = mechanize.Browser() # Enable cookie support for urllib2 cookiejar = cookielib.LWPCookieJar() br.set_cookiejar(cookiejar) # Broser options br.set_handle_equiv(True) br.set_handle_gzip(True) br.set_handle_redirect(True) br.set_handle_referer(True) br.set_handle_robots

Rails 3 Mechanize - SocketError: getaddrinfo: Host or name not known

微笑、不失礼 提交于 2019-12-24 00:05:06
问题 I am using mechanize and i get this error. Can someone please help me. I have set meta refresh to true. Error log: SocketError: getaddrinfo: Host or name not known form C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in 'initiallize' form C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in 'open' form C:/Ruby192/lib/ruby/1.9.1/net/http.rb:644:in 'block in connect' form C:/Ruby192/lib/ruby/1.9.1/timeout.rb:44:in 'timeout' form C:/Ruby192/lib/ruby/1.9.1/timeout.rb:87:in 'timeout' form C:/Ruby192/lib/ruby/1

Forcing Mechanize to use SSLv3

佐手、 提交于 2019-12-23 16:32:14
问题 How would you force mechanize to use SSLv3 for HTTPS URLs that require it? If I try to use mechanize with all SSLv3-only URLs, I get the error: URLError: <urlopen error [Errno 1] _ssl.c:504: error:140773E8:SSL routines:SSL23_GET_SERVER_HELLO:reason(1000)> 回答1: A dirty answer... not requiring patching. import ssl from ssl import PROTOCOL_SSLv23, PROTOCOL_SSLv3, CERT_NONE, SSLSocket def monkey_wrap_socket(sock, keyfile=None, certfile=None, server_side=False, cert_reqs=CERT_NONE, ssl_version

ImportError: No module named '_version' when importing mechanize

蹲街弑〆低调 提交于 2019-12-23 14:58:44
问题 I installed mechanize via pip and get an errer when I import the module: $ python Python 3.5.2 (default, Jun 28 2016, 08:46:01) [GCC 6.1.1 20160602] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import mechanize Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/lib/python3.5/site-packages/mechanize/__init__.py", line 119, in <module> from _version import __version__ ImportError: No module named '_version' The file -version

What does “module object is not callable” mean?

本小妞迷上赌 提交于 2019-12-23 12:24:29
问题 I'm using the .get_data() method with mechanize, which appears to print out the html that I want. I also check the type of what it prints out, and the type is 'str'. But when I try to parse the str with BeautifulSoup, I get the following error: --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-163-11c061bf6c04> in <module>() 7 html = get_html(first[i],last[i]) 8 print type(html) ----> 9 print parse_page(html)

using mechanize and got the uninitialized constant Object::WWW (NameError)

你说的曾经没有我的故事 提交于 2019-12-23 10:58:56
问题 I'm using mechanize in windows 7 x64 OS, but got the the uninitialized constant Object::WWW (NameError), the code is very simple: require 'rubygems' require 'mechanize' agent = WWW::Mechanize.new error occurs at the line agent = WWW::Mechanize.new any help is appreciated! 回答1: remove the WWW:: - that got removed a long time ago. 回答2: While googling found the following code, may be useful to you. @a = Mechanize.new { |agent| agent.user_agent = 'Mozilla/5.0 (Windows; U; Windows NT 6.1; es-ES;

Mechanize & Sinatra conflict

我只是一个虾纸丫 提交于 2019-12-23 10:42:22
问题 I've writter a simple web crawler using Mechanize as a command-line utility. Then I decided to create web app with Sinatra , but got stuck with this error when trying to run the local webserver: /home/nazar/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.2/lib/sinatra/base.rb:1569:in `run!': undefined method `run' for HTTP:Module (NoMethodError) from /home/nazar/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.2/lib/sinatra/main.rb:25:in `block in <module:Sinatra>' The source code is dead simple:

Mechanize & Sinatra conflict

一世执手 提交于 2019-12-23 10:42:10
问题 I've writter a simple web crawler using Mechanize as a command-line utility. Then I decided to create web app with Sinatra , but got stuck with this error when trying to run the local webserver: /home/nazar/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.2/lib/sinatra/base.rb:1569:in `run!': undefined method `run' for HTTP:Module (NoMethodError) from /home/nazar/.rvm/gems/ruby-2.0.0-p195/gems/sinatra-1.4.2/lib/sinatra/main.rb:25:in `block in <module:Sinatra>' The source code is dead simple:

how to log into vBulletin 3.6 using mechanize (ruby)

有些话、适合烂在心里 提交于 2019-12-23 04:14:13
问题 the html looks like below or you can find it here http://www.vbulletin.org/forum/index.php <!-- login form --> <form action="login.php?do=login" method="post" onsubmit="md5hash(vb_login_password, vb_login_md5password, vb_login_md5password_utf, 0)"> <script type="text/javascript" src="clientscript/vbulletin_md5.js?v=3612"></script> <table cellpadding="0" cellspacing="1" border="0"> <tr> <td class="smallfont" align="left"><label for="navbar_username">User Name</label></td> <td class="smallfont"