Python Forum
Click on button with python mechanize
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Click on button with python mechanize
#1
Hello,

I would like to click a button using mechanize but I can't find the right code.

Until then, I had succeeded because I was going through the mobile version of twitter and I didn't have to deal with javascript.

Apparently for this page it is not possible. I would like to avoid using selenium, is it possible to do a
br.submit()
on the blue button below?

[Image: zWNGswn.png]

Thank you !
Reply
#2
try this
br.submit(id='allow')
if there is javascript in there, then you cannot do it with mechanize. You will need selenium.
Recommended Tutorials:
Reply
#3
Thank you very much for your answer.

I got this error:

Quote:Traceback (most recent call last):
File "test.Acc0unt_Cr3at0r.2.py", line 165, in <module>
br.submit(id='allow')
File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 541, in submit
return self.open(self.click(*args, **kwds))
File "/usr/local/lib/python2.7/dist-packages/mechanize/_mechanize.py", line 530, in click
request = self.form.click(*args, **kwds)
AttributeError: 'NoneType' object has no attribute 'click'
Reply
#4
A couple ways to test if javascript is the issue.

1) turn javascript off on your browser and see if the button is selectable or even viewable. If not then javascript is providing it. I dont have a twitter account so i cannot test it.

2) See if BeautifulSoup can see the button. If it cannot then most likely it is javascript.

I would check that first. If javascript is the problem, then your are shit out of luck and must use selenium.
Recommended Tutorials:
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  cant click button by script at page michael1834 1 994 Dec-08-2023, 04:44 PM
Last Post: SpongeB0B
  Click on a button on web page using Selenium Pavel_47 7 4,564 Jan-05-2023, 04:20 AM
Last Post: ellapurnellrt
  Show HTML in Python application and handle click SamHobbs 2 2,661 Sep-28-2021, 06:27 PM
Last Post: SamHobbs
  Automating Captcha form submission with Mechanize Dexty 2 3,257 Aug-03-2021, 01:02 PM
Last Post: Dexty
  button click error rafarangel 2 3,082 Feb-11-2021, 08:19 PM
Last Post: buran
  Log In Button Won't Click - Python Selenium Webdriver samlee916 2 3,770 Jun-07-2020, 04:42 PM
Last Post: samlee916
  How to click facebook message button JanelleGuthrie 2 2,370 May-14-2020, 06:02 PM
Last Post: Larz60+
  Contact form button click action Man_from_India 1 2,744 Feb-01-2020, 06:21 PM
Last Post: snippsat
  HOWTO? Login DSL Modem with Python Requests: need Click "Apply" Button Webtest 4 8,406 Aug-20-2019, 04:03 PM
Last Post: johnmina
  Selenium click on popup button??? GuJu 7 7,725 Jul-20-2019, 09:21 AM
Last Post: Nizam

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020