Python Forum
Parsing html page and working with checkbox (on a captcha)
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Parsing html page and working with checkbox (on a captcha)
#11
(Jan-27-2021, 11:52 AM)buran Wrote: Please, don't play stupid or your presence here will not last much longer.

Ok. Is my question "why I am not receiving notification of replies to my message?" also stupid?
Could you answer, please?
Reply
#12
(Jan-27-2021, 12:07 PM)straannick Wrote: Could you answer, please?
No, only some of the admins can check. I would suggest you post about it in Board section of the forum so that they see it.

There was similar issue some months ago https://python-forum.io/Thread-Anyone-el...rum-emails
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#13
No ideas?
Reply
#14
If i test recaptcha there is no problem to find the iframe and click on check box.
The problem is that Buster: Captcha Solver for Humans pop up every time and has to be solved.
A couple links that try solve this.
How to bypass reCaptcha V2 with Selenium?
How to bypass recaptcha V2 with Python [Educational Video] .
Reply
#15
(Feb-01-2021, 02:14 PM)snippsat Wrote: If i test recaptcha there is no problem to find the iframe and click on check box.
[/url].
Thank you, snippsat. My mistake was that in my example I did not notice iframe, which I wrote about earlier.
Since I'm new to Python programming, could you be more specific? Let's see example of your test link (see captcha-1.jpg).
driver = webdriver.Chrome()
driver.get(“https://www.google.com/recaptcha/api2/demo”)
driver.switch_to.frame(0)
print("--- a ---")
elem_capt = driver.find_elements_by_class_name("recaptcha-checkbox-checkmark")
print("--- b ---")
elem_capt.select()
print("--- c ---")
and the result
Output:
--- a --- --- b --- Traceback (most recent call last): File "F:\_документы OI\_my\проекты\Python\goo_login.py", line 74, in <module> main() File "F:\_документы OI\_my\проекты\Python\goo_login.py", line 30, in main elem_capt.select() AttributeError: 'list' object has no attribute 'select' Process finished with exit code 1
So I see the same error as in my main post.
By the way, if I remove "driver.switch_to.frame(0)" I get the same.

So what should I "find" as elem_capt?
Reply
#16
Quote:AttributeError: 'list' object has no attribute 'select'
Return a list object to get,so most use it like this.
elem_capt[0].select()
Here my setup with different tests,but has to solve Buster manually.
So most look at links posted that try to bypass Buster solver.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver import ActionChains
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as ec
from selenium.webdriver.common.by import By
from selenium.webdriver.common.keys import Keys
import time

#--| Setup
options = Options()
#options.add_argument("--headless")
#options.add_argument('--log-level=3')
options.add_argument("user-data-dir=cookies") # Try so save cookies local
options.add_argument('--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/88.0.4324.104 Safari/537.36')
options.add_argument("--disable-blink-features")
options.add_argument("--disable-blink-features=AutomationControlled")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
options.add_experimental_option('useAutomationExtension', False)
browser = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
browser.get('https://www.google.com/recaptcha/api2/demo')
# Find iframe
captcha_iframe = WebDriverWait(browser, 10).until(ec.presence_of_element_located((By.TAG_NAME, 'iframe')))
# Move to element
ActionChains(browser).move_to_element(captcha_iframe).click().perform()
# Click on checkbox
captcha_box = WebDriverWait(browser, 10).until(ec.presence_of_element_located((By.ID, 'g-recaptcha-response')))
browser.execute_script("arguments[0].click()", captcha_box)
time.sleep(30) # Time to solve
send = browser.find_elements_by_css_selector('#recaptcha-demo-submit')
send[0].click() 
Reply
#17
(Feb-03-2021, 04:11 PM)snippsat Wrote:
Quote:AttributeError: 'list' object has no attribute 'select'
Return a list object to get,so most use it like this.

Here my setup with different tests, but has to solve Buster manually.
So most look at links posted that try to bypass Buster solver.
Thank you, but for me this is strange and complicated example.
Try to open link manually, check captcha checkbox, press button and you'll see "check is successfull".
No need for Buster solver. But your code provoke (execute_script) all those buster pictures!
In my example no buster, I need only check captcha checkbox - when I do it manually.

So my question is - how to imitate THIS user action?
An alternative solution would be to use a python program after manual login - is this possible?


elem_capt[0].select()
doesn't work because list is zero-length
Reply
#18
(Feb-04-2021, 01:16 PM)straannick Wrote: Try to open link manually, check captcha checkbox, press button and you'll see "check is successfull".
No need for Buster solver. But your code provoke (execute_script) all those buster pictures!
In my example no buster, I need only check captcha checkbox - when I do it manually.
There is usually no need when do it yourself in browser.
There is a difference when try from Selenium,then dos then Buster solver always show up.
That why you see i try different stuff to hide that i use Selenium.

So if fix your code that do work,you will see that the Buster solver pop up.
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
import time

#--| Setup
options = Options()
#options.add_argument("--headless")
#options.add_argument('--log-level=3')
# Your path to chromedriver.exe most be in Windows environment Path or same folder as run script
driver = webdriver.Chrome(executable_path=r'C:\cmder\bin\chromedriver.exe', options=options)
#--| Parse or automation
driver.get('https://www.google.com/recaptcha/api2/demo')
time.sleep(2)
# Switch to recaptcha frame
frames = driver.find_elements_by_tag_name("iframe")
driver.switch_to.frame(frames[0])
time.sleep(2)
# Click on checkbox to activate recaptcha,Buster pop up
driver.find_element_by_class_name("recaptcha-checkbox-border").click()
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Photo Disable checkbox of google maps markers/labels using selenium erickkill 0 1,215 Nov-25-2021, 12:20 PM
Last Post: erickkill
  <title> django page title dynamic and other field (not working) lemonred 1 2,069 Nov-04-2021, 08:50 PM
Last Post: lemonred
  Automating Captcha form submission with Mechanize Dexty 2 3,257 Aug-03-2021, 01:02 PM
Last Post: Dexty
  HTML multi select HTML listbox with Flask/Python rfeyer 0 4,532 Mar-14-2021, 12:23 PM
Last Post: rfeyer
  Saving html page and reloading into selenium while developing all xpaths Larz60+ 4 4,104 Feb-04-2021, 07:01 AM
Last Post: jonathanwhite1
  API auto-refresh on HTML page using Flask toc 2 11,747 Dec-23-2020, 02:00 PM
Last Post: toc
  Selenium Parsing (unable to Parse page after loading) oneclick 7 5,890 Oct-30-2020, 08:13 PM
Last Post: tomalex
  Help: Beautiful Soup - Parsing HTML table ironfelix717 2 2,623 Oct-01-2020, 02:19 PM
Last Post: snippsat
  [FLASK] checkbox onclick event Mad0ck 2 4,772 May-14-2020, 09:35 AM
Last Post: Mad0ck
  Python3 + BeautifulSoup4 + lxml (HTML -> CSV) - How to loop to next HTML/new CSV Row BrandonKastning 0 2,329 Mar-22-2020, 06:10 AM
Last Post: BrandonKastning

Forum Jump:

User Panel Messages

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