mechanize

mechanize python click a button

非 Y 不嫁゛ 提交于 2019-11-26 08:34:59
问题 I have a form with <input type=\"button\" name=\"submit\" /> button and would like to be able to click it. I have tried mech.form.click(\"submit\") but that gives the following error: ControlNotFoundError: no control matching kind \'clickable\', id \'submit\' mech.submit() also doesn\'t work since its type is button and not submit. Any ideas? Thanks. 回答1: clicking a type="button" in a pure html form does nothing. For it to do anything, there must be javascript involved. And mechanize doesn't

Mechanize and Javascript

送分小仙女□ 提交于 2019-11-26 08:16:23
问题 I want to use Mechanize to simulate browsing to a web page with active JavaScript, including DOM Events and AJAX, and so far I\'ve found no way to do that. I looked at some Python client browsers that support JavaScript like Spynner and Zope, and none of them really work for me. Spynner crashes PyQt all the time, and Zope doesn\'t support JavaScript as it seems. Is there a way to simulate browsing with Python only (no extra processes) like WATIR or libraries that manipulate Firefox or

adding directory to sys.path /PYTHONPATH

*爱你&永不变心* 提交于 2019-11-26 06:28:06
问题 I am trying to import a module from a particular directory. The problem is that if I use sys.path.append(mod_directory) to append the path and then open the python interpreter, the directory mod_directory gets added to the end of the list sys.path. If I export the PYTHONPATH variable before opening the python interpreter, the directory gets added to the start of the list. In the latter case I can import the module but in the former, I cannot. Can somebody explain why this is happening and

How do I use Mechanize to process JavaScript?

坚强是说给别人听的谎言 提交于 2019-11-26 03:16:44
问题 I\'m connecting to a web site, logging in. The website redirects me to new pages and Mechanize deals with all cookie and redirection jobs, but, I can\'t get the last page. I used Firebug and did same job again and saw that there are two more pages I had to pass with Mechanize. I took a quick look at the pages and saw that there is some JavaScript and HTML code but couldn\'t understand it because it doesn\'t look like normal page code. What are those pages for? How they can redirect to other

Unable to import a module that is definitely installed

落花浮王杯 提交于 2019-11-26 01:47:03
问题 After installing mechanize, I don\'t seem to be able to import it. I have tried installing from pip, easy_install, and via python setup.py install from this repo: https://github.com/abielr/mechanize. All of this to no avail, as each time I enter my Python interactive I get: Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type \"help\", \"copyright\", \"credits\" or \"license\" for more information. >>> import mechanize Traceback (most recent call last): File \"<stdin>\",

Unable to import a module that is definitely installed

孤街浪徒 提交于 2019-11-25 21:35:36
After installing mechanize , I don't seem to be able to import it. I have tried installing from pip, easy_install, and via python setup.py install from this repo: https://github.com/abielr/mechanize . All of this to no avail, as each time I enter my Python interactive I get: Python 2.7.3 (default, Aug 1 2012, 05:14:39) [GCC 4.6.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import mechanize Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: No module named mechanize >>> The installations I ran previously reported that