mechanize

Changing the link in python mechanize

给你一囗甜甜゛ 提交于 2019-12-23 03:56:36
问题 I am trying to write a python script that will generate the rank-list of my batch. For this I simply need to change the roll-number parameter of the link using inspect element feature in web-browser. The link(relative) looks something like: /academic/utility/AcademicRecord.jsp?loginCode=000&loginnumber=000&loginName=name&Home=ascwebsite I just need to change the loginCode to get the grade of my batch-mates. I am trying to use python to iterate through all the roll-numbers and generate a rank

Login via the browser to facebook and google without using their APIs, using Python

為{幸葍}努か 提交于 2019-12-23 02:46:06
问题 Is there any way of to login via the browser to facebook and google, but without using the provided APIs? So far I have tried mechanize with cookielib , webbrowser , requests and selenium , but I did not get any satisfying results. The closest I got was to log in using mechanize + cookielib but via command line. I have an app and all what I want it to do is to open a browser and open either the facebook or the google page and to automatically log me in using the provided user name and

How to get 'value' of select tag based on content of select tag, using Nokogiri

纵然是瞬间 提交于 2019-12-23 01:52:34
问题 How would one get the contents of the 'value' attribute of a select tag, based on content of the select tag (i.e. the text wrapped by option), using Nokogiri? For example, given the following HTML: <select id="options" name="options"> <option value="1">First Option - 4</option> <option value="2">Second Option - 5</option> <option value="3">Third Option - 6</option> </select> I would like to be able to specify a string (e.g. 'First Option') and have the contents of the 'value' attribute

How to extract text from <script> tag by using nokogiri and mechanize?

a 夏天 提交于 2019-12-22 18:27:27
问题 this is a part of the source code of a bookings web site: <script> booking.ensureNamespaceExists('env'); booking.env.b_map_center_latitude = 53.36480155016638; booking.env.b_map_center_longitude = -2.2752803564071655; booking.env.b_hotel_id = '35523'; booking.env.b_query_params_no_ext = '?label=gen173nr-17CAEoggJCAlhYSDNiBW5vcmVmaFCIAQGYAS64AQTIAQTYAQHoAQH4AQs;sid=e1c9e4c7a000518d8a3725b9bb6e5306;dcid=1'; </script> And I want to extract booking.env.b_hotel_id . So that i would get the value

is using threads and ruby mechanize safe?

心不动则不痛 提交于 2019-12-22 14:58:37
问题 Does anyone ever see a lot of errors like this: Exception `Net::HTTPBadResponse' at /usr/lib/ruby/1.8/net/http.rb:2022 - wrong status line: _SOME HTML CODE HERE_ When using threads and mechanize? I'm relatively certain that this is some bad behavior between threads and the net/http library, but does anyone have any advice as far as the upper limit of threads you want to run at once when using mechanize/nethttp? And how can I capture this kind of exception because rescue Net::HTTPBadResponse

Mechanize difference between br.click_link() and br.follow_link()

心已入冬 提交于 2019-12-22 09:37:10
问题 I am using mechanize to automate some form submissions. To do that I require to go to the home page of some website, click on a link with a particular text which redirects me to an another page and fill in the form in the new page. I tried using response = br.follow_link(text_regex="sometext") for f in response.forms() print f.name The error Message I got was AttributeError: closeable_response instance has no attribute 'forms' When I tried for f in br.forms() print f.name It prints the name

Mechanize in Python - Redirect is not working after submit

十年热恋 提交于 2019-12-22 08:24:04
问题 I just started using mechanize in Python and I'm having some problems with it already. I've looked around on StackOverflow and on Google and I've seen people say that the documentation is great and that it should be easy to get it working, but I think I don't know how to look for that documentation since all I can find is code examples which don't really teach me how to do the particular things I'm trying to do. If anyone could point me to such documentation, I'd be glad to read it myself and

Mechanize - How to follow or “click” Meta refreshes in rails

一笑奈何 提交于 2019-12-22 06:00:23
问题 I have a bit trouble with Mechanize. When a submit a form with Mechanize. I am come to a page with one meta refresh and there is no links. My question is how do i follow the meta refresh? I have tried to allow meta refresh but then i get a socket error. Sample code require 'mechanize' agent = WWW::Mechanize.new agent.get("http://euroads.dk") form = agent.page.forms.first form.username = "username" form.password = "password" form.submit page = agent.get("http://www.euroads.dk/system/index.php

Mechanize - How to follow or “click” Meta refreshes in rails

♀尐吖头ヾ 提交于 2019-12-22 06:00:18
问题 I have a bit trouble with Mechanize. When a submit a form with Mechanize. I am come to a page with one meta refresh and there is no links. My question is how do i follow the meta refresh? I have tried to allow meta refresh but then i get a socket error. Sample code require 'mechanize' agent = WWW::Mechanize.new agent.get("http://euroads.dk") form = agent.page.forms.first form.username = "username" form.password = "password" form.submit page = agent.get("http://www.euroads.dk/system/index.php

Python mechanize module not found

吃可爱长大的小学妹 提交于 2019-12-22 01:15:16
问题 My python version is: Python 2.7 I did an easy_install mechanize then I tried running a script and I'm getting this: File "test.py", line 2, in <module> import mechanize ImportError: No module named mechanize If you need any other information let me know. 回答1: Try this in case pip or easy_install, for whatever reason, aren't working: Download the source code from http://pypi.python.org/packages/source/m/mechanize/mechanize-0.2.5.tar.gz Unzip the package, go to the command line, change into