mechanize

How to select a Radio Button?

谁都会走 提交于 2019-12-05 03:44:14
I am using mechanize and I am trying to select a button from a radio button list. This list has 5 items. How can I select the first item? Docs didn't help me. >>> br.form <ClientForm.HTMLForm instance at 0x9ac0d4c> >>> print(br.form) <form1 POST http://www.example.com application/x-www-form-urlencoded <HiddenControl(DD=17010200) (readonly)> <RadioControl(prodclass=[1, 2, 3, 4, 5])> <SubmitControl(submit=text) (readonly)>> It should be as simple as br.form['prodclass'] = ['1'] I prefer the more verbose: br.form.set_value(['1'],name='prodclass') 来源: https://stackoverflow.com/questions/3798138

How to read someone else's forum

大城市里の小女人 提交于 2019-12-05 03:40:07
问题 My friend has a forum, which is full of posts containing information. Sometimes she wants to review the posts in her forum, and come to conclusions. At the moment she reviews posts by clicking through her forum, and generates a not necessarily accurate picture of the data (in her brain) from which she makes conclusions. My thought today was that I could probably bang out a quick Ruby script that would parse the necessary HTML to give her a real idea of what the data is saying. I am using Ruby

How to make mechanize wait for web-page 'full' load?

喜欢而已 提交于 2019-12-05 03:00:39
I want to scrape some web page which loads its components dynamically. This page has an onload script, and I can see the complete page 3-5 seconds after typing the URL into my browser. The problem is, when I call br.open('URL') , the response is the web page at 0 seconds. There is a difference 3-5 seconds later between the HTML (which I want) and result of br.open('URL') . FallenAngel Working a webpage with a rich javascripts content with mechanize is not much easy, but there are ways to get what you want according to different situations. If some json requests are made to create the content,

beautifulsoup and mechanize to get ajax call result

社会主义新天地 提交于 2019-12-05 01:18:08
问题 hi im building a scraper using python 2.5 and beautifulsoup but im stuble upon a problem ... part of the web page is generating after user click on some button, whitch start an ajax request by calling specific javacsript function using proper parameters is there a way to simulate user interaction and get this result? i come across a mechanize module but it seems to me that this is mostly used to work with forms ... i would appreciate any links or some code samples thanks 回答1: ok so i have

How can I keep WWW::Mechanize from following redirects?

家住魔仙堡 提交于 2019-12-05 01:12:44
I have a Perl script that uses WWW::Mechanize to read from a file and perform some automated tasks on a website. However, the website uses a 302 redirect after every time I request a certain page. I don't want to be redirected (the page that it redirects to takes too long to respond); I just want to loop through the file and call the first link over and over. I can't figure out how to make WWW::Mechanize NOT follow redirects. Any suggestions? Alexandr Ciornii WWW::Mechanize is a subclass of LWP::UserAgent . So you can use any LWP::UserAgent methods. my $mech = WWW::Mechanize->new(); $mech-

how do i set a timeout value for python's mechanize?

风流意气都作罢 提交于 2019-12-04 23:15:12
How do i set a timeout value for python's mechanize? Alex is correct: mechanize.urlopen takes a timeout argument. Therefore, just insert a number of seconds in floating point : mechanize.urlopen('http://url/', timeout=30.0) . The background, from the source of mechanize.urlopen : def urlopen(url, data=None, timeout=_sockettimeout._GLOBAL_DEFAULT_TIMEOUT): ... return _opener.open(url, data, timeout) What is mechanize._sockettimeout._GLOBAL_DEFAULT_TIMEOUT you ask? It's just the socket module's setting. import socket try: _GLOBAL_DEFAULT_TIMEOUT = socket._GLOBAL_DEFAULT_TIMEOUT except

Open SSL Errors for Ruby on Windows 7

这一生的挚爱 提交于 2019-12-04 21:19:17
I'm running on Windows 7 normal OS. Ruby, SSL, and Windows don't like each other, so simple commands like these don't work for me and it's giving me a real headache. I've tried getting RVM, updating my environmental variables, practically everything. I don't know what the solution is. Is there a solution to install the OpenSSL gem for Ruby 1.9.3? require 'mechanize' agent = Mechanize.new page = agent.get('https://any-ssl-site-here.com') puts page Azolo So whenever you try to use libraries to access https urls on Windows they basically fail because OpenSSL doesn't know where to look for the ca

Python mechanize module not found

夙愿已清 提交于 2019-12-04 19:18:54
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. 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 the folder that was extracted and type: python setup.py install If you're on Linux/Mac, you may need to type

Python Mechanize keeps giving me 'response_seek_wrapper' when I try to use .open

▼魔方 西西 提交于 2019-12-04 19:10:49
I'm not sure what's going on, as the script used to work (before I messed around with my python on my system...) But when I try something along the lines of import mechanize browser = mechanize.Browser() browser.open("http://google.com") I get something like <response_seek_wrapper at 0x10123fd88 whose wrapped object = <closeable_response at 0x101232170 whose fp = <socket._fileobject object at 0x1010bf5f0>>> Does anyone know why this is and what the fix is? thanks! it's not an exception, is it? nothing wrong is happening, you just got a return value, which is esentially a response object,

Ruby Mechanize login not working

让人想犯罪 __ 提交于 2019-12-04 19:05:18
Let me set the stage for what I'm trying to accomplish. In a physics class I'm taking, my teacher always likes to brag about how impossible it is to cheat in her class, because all of her assignments are done through WebAssign. The way WebAssign works is this: Everyone gets the same questions, but the numbers used in the question are random variables, so each student has different numbers, thus a different answer. So I've been writing ruby scripts to solve the question's for people by just imputing your specific numbers. I would like to automate this process using mechanize. I've used