lundi 4 mai 2015

Check a ReCAPTCHA checkbox with VBA in Excel

I got a input form and a ReCAPTCHA checkbox in a web page. I must fill the form and click the checkbox. Fist part is done in this way:

Sub Try()
Dim objIE As Object

Set objIE = CreateObject("InternetExplorer.Application")

objIE.Visible = True
objIE.navigate "MyWebPage"
objIE.document.forms(0).username.Value = "SomeMyData"      'Till here all OK
objIE.document.getElementById("recaptcha-anchor")(0).Click    'Here is the problem

objIE.Quit
Set objIE = Nothing
End Sub

Here the part of the web page BEFORE click:

<span tabindex="0" aria-disabled="false" aria-labelledby="recaptcha-anchor-label" class="recaptcha-checkbox goog-inline-block recaptcha-checkbox-unchecked rc-anchor-checkbox" role="checkbox" aria-checked="false" id="recaptcha-anchor" dir="ltr">
<div style="" class="recaptcha-checkbox-border" role="presentation"></div>
<div style="" class="recaptcha-checkbox-borderAnimation" role="presentation"></div>
<div style="transform: rotate(0deg);" class="recaptcha-checkbox-spinner" role="presentation"></div>
<div style="" class="recaptcha-checkbox-spinnerAnimation" role="presentation"></div>
<div class="recaptcha-checkbox-checkmark" role="presentation"></div>
</span>

Here AFTER click:

<span tabindex="0" style="overflow: visible;" aria-disabled="false" aria-labelledby="recaptcha-anchor-label" class="recaptcha-checkbox goog-inline-block recaptcha-checkbox-unchecked rc-anchor-checkbox recaptcha-checkbox-checked" role="checkbox" aria-checked="true" id="recaptcha-anchor" dir="ltr">
<div style="display: none;" class="recaptcha-checkbox-border" role="presentation"></div>
<div style="" class="recaptcha-checkbox-borderAnimation" role="presentation"></div>
<div style="transform: rotate(0deg);" class="recaptcha-checkbox-spinner" role="presentation"></div>
<div style="" class="recaptcha-checkbox-spinnerAnimation" role="presentation"></div>
<div style="" class="recaptcha-checkbox-checkmark" role="presentation"></div>
</span>

I wish only check the checkbox via VBA-Excel code (NOT solve captcha). Thanks.




Aucun commentaire:

Enregistrer un commentaire