Need help grabbing input element of recaptcha input box using my scraper

simpleonline12

New member
Sep 29, 2009
191
3
0
I have an element that I am trying to grab/scrape during my visit to the website.

I have an element scraper that I created and use to grab any input elements on the screen and grab them by their element.id

Works great on all the "other" input boxes that I am trying to grab except this one.

If I manually grab the element using Firebug I can insert the element by Id and it works fine to pass the variable back to the website however I am trying to avoid Firebug and use my contextmenu that I have created to grab web elements.

I believe it's nested and when I try to grab this element by id it comes up zero.

Here is the portion of the application that grabs the input element'

Code:
If element.TagName = "INPUT" Then[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.ContextMenuStrip1.Show(Me.WebBrowser1.PointToScreen(e.MousePosition))[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.InputToolStripMenuItem.ShowDropDown()[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        End If

I have a context menu setup on my form that when I click the input box on the screen the drop down box appears for me to click on.

I have the drop down box set to grab the element it's id and place that into a richtextbox.

Here is the code for that portion of the application.

Code:
Dim Username As String = element.GetAttribute("id")[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]Richtextbox1.text = richtextbox1.text & Username & vbnewline &_ [/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]"" & vbnewline & _[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]""[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]


I've tried everything that I can think of to grab this input box that I am unable to grab the element off of.

I coded up my drop down context menu to appear if any of these are true for the element that I click on.

Code:
        element = doc.GetElementFromPoint(e.MousePosition)[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        If element.TagName = "INPUT" Then[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.ContextMenuStrip1.Show(Me.WebBrowser1.PointToScreen(e.MousePosition))[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.InputToolStripMenuItem.ShowDropDown()[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        End If[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        If element.TagName = "SELECT" Then[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.ContextMenuStrip1.Show(Me.WebBrowser1.PointToScreen(e.MousePosition))[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.InputToolStripMenuItem.ShowDropDown()[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        End If[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white] [/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        If element.TagName = "DIV" Then[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.ContextMenuStrip1.Show(Me.WebBrowser1.PointToScreen(e.MousePosition))[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.InputToolStripMenuItem.ShowDropDown()[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        End If[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white] [/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        If element.TagName = "IMG" Then[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.ContextMenuStrip1.Show(Me.WebBrowser1.PointToScreen(e.MousePosition))[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.InputToolStripMenuItem.ShowDropDown()[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        End If[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white] [/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        If element.TagName = "TABLE" Then[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.ContextMenuStrip1.Show(Me.WebBrowser1.PointToScreen(e.MousePosition))[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.InputToolStripMenuItem.ShowDropDown()[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        End If[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white] [/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        If element.TagName = "TBODY" Then[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.ContextMenuStrip1.Show(Me.WebBrowser1.PointToScreen(e.MousePosition))[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.InputToolStripMenuItem.ShowDropDown()[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        End If[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white] [/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        If element.TagName = "SCRIPT" Then[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.ContextMenuStrip1.Show(Me.WebBrowser1.PointToScreen(e.MousePosition))[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]            Me.InputToolStripMenuItem.ShowDropDown()[/COLOR][/FONT][/B]
[B][FONT=Arial][COLOR=white]        End If

On this input box I've tried to grab the element by ID, name, type, etc"

Here is the code for the element that I am needing help grabbing the element by.

2uo5kpj.jpg

 


Have you tried getting all the elements and then filtering by id or name to select the element you want?

Can u grab the parent element? if so then try to use that element to get it child element. e.g. parentElement.getElementById("theId").

Does the source for the element show up in the source of the WebBrowser's Document object?