CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jan 2004
    Location
    TX, USA
    Posts
    347

    [RESOLVED] Frustrated - Webbrowser1 !!!

    I just don't understand something.
    I go to a web site. http://davidgrayspeoplefinder.com/
    It's form appears on my screen.

    Code:
       On Error Resume Next
       For z = 0 To WebBrowser1.Document.Forms(0).length - 1
          Debug.Print WebBrowser1.Document.Forms(0)(z).Name _
                & " " & WebBrowser1.Document.Forms(0)(z).Type _
                & " " & WebBrowser1.Document.Forms(0)(z).Value
       Next z
       On Error GoTo 0
    The code doesn't see anything!

    Well, if it's on my screen, why I can't I insert username and password and click.

    Frustrated but determined
    Cathy
    Cathy
    Jan 2004 - NEWBIE to VB6
    Any and all help appreciated

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: Frustrated - Webbrowser1 !!!

    Are you making sure that the document is complete first before executing this code?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Jan 2004
    Location
    TX, USA
    Posts
    347

    Re: Frustrated - Webbrowser1 !!!

    Yes, and it does complete.

    I am wondering if the website is sending the webpage and then deleting the information in the temp int directory.

    I'll clear my temp internet dir then request the website and only one file is there.

    Cathy
    Cathy
    Jan 2004 - NEWBIE to VB6
    Any and all help appreciated

  4. #4
    Join Date
    May 2002
    Posts
    10,943

    Re: Frustrated - Webbrowser1 !!!

    No. The browser itself controls the temp internet files, no scripting can do that. What I don't understand is your z variable attempting to read the form. WebBrowser1.Document.Forms(0)(z) is invalid because WebBrowser1.Document.Forms(0) returns the form itself, not the objects in it. If you want the <input> tags, you will have to do WebBrowser1.Document.Forms(0).ELEMENT_NAME.value.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Jan 2004
    Location
    TX, USA
    Posts
    347

    Re: Frustrated - Webbrowser1 !!!

    I am trying to get the names of the elements.

    In all of my test runs I removed the 'On Error Resume Next' and everthing works perfectly except at "http://davidgrayspeoplefinder.com/"
    For z = 0 To WebBrowser1.Document.Forms(0).length - 1

    Generates a Run time error '91'
    Object variable or With block variable not set

    Using Goggle advanced search page, http://www.google.com/advanced_search?hl=en
    my code works perfectly and generates the following:

    as_q text
    hl hidden en
    num select-one 10
    btnG submit Google Search
    as_epq text
    as_oq text
    as_eq text
    lr select-one
    as_ft select-one i
    as_filetype select-one
    as_qdr select-one all
    as_nlo text
    as_nhi text
    as_occt select-one any
    as_dt select-one i
    as_sitesearch text
    as_rights select-one
    safe radio images
    safe radio active

    Works great at another website I use often
    http://wc.rootsweb.com/cgi-bin/igm.cgi

    op hidden Search
    includedb hidden
    lang hidden en
    ti hidden
    surname text
    stype select-one Exact
    given text
    lskip checkbox 1
    bplace text
    bskip checkbox 1
    byear text
    brange select-one 0
    dplace text
    dskip checkbox 1
    dyear text
    drange select-one 0
    mplace text
    mskip checkbox 1
    myear text
    mrange select-one 0
    father text
    mother text
    spouse text
    skipdb text
    period select-one All
    hd checkbox 1
    hn checkbox 1
    hs checkbox 1
    fuzzy checkbox Y
    submit.x submit Search

    Please help
    Cathy
    Cathy
    Jan 2004 - NEWBIE to VB6
    Any and all help appreciated

  6. #6
    Join Date
    May 2002
    Posts
    10,943

    Re: Frustrated - Webbrowser1 !!!

    Well, the only difference is that the sites it works on have more than one form. Have you tried it on different site that only has one form besides davidgrayspeoplefinder?
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  7. #7
    Join Date
    Jan 2004
    Location
    TX, USA
    Posts
    347

    Re: Frustrated - Webbrowser1 !!!

    Well, I went to my banking site and it doesn't work there either.

    I really don't know what I'm doing here so I thought someone would have the answer.

    It's just suprising that the form is sitting on my desktop but I can auto enter anything.

    Thanks for your help,
    Cathy
    Cathy
    Jan 2004 - NEWBIE to VB6
    Any and all help appreciated

  8. #8
    Join Date
    May 2002
    Posts
    10,943

    Re: Frustrated - Webbrowser1 !!!

    Why don't you try giving the form a name and then using Webbrowser1.document.FORMNAME...
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  9. #9
    Join Date
    Nov 2005
    Location
    Omaha, Nebraska, USA
    Posts
    696

    Re: Frustrated - Webbrowser1 !!!

    I thought it odd too, that I could load the page in a WebBrowser and your code wouldn't find a form, but viewing the source showed a FORM tag.

    So, I looked through the WebBrowser1.Document object.

    What it is, is that the page you're looking at is inside a frame. The page you actually visit has a FRAMESET and a FRAME. Here's the HTML source of the page in that link (gotten by clicking on the View menu of the browser, not right clicking on the page and selecting View Source):
    Code:
    <!--redirect1--><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN"
    "http://www.w3.org/TR/html4/frameset.dtd">
    <html>
    <head>
    <title>David Gray's People Finder</title>
    <META NAME="Keywords" CONTENT="adoption,search,genealogy,archives,texas birth index,texas marraige index,texas divorce index,texas death index index,vital records,vital">
    <META NAME="Description" CONTENT="Search 500mil people including the TX, CA, KY etc... Birth/Death/Marriage indexes and Texas Birth/Death/Delayed Books and more...">
    </head>
    	<frameset frameborder="0" framespacing="0" border="0" rows="100%,*">
    	    <frame name="MYTOPFRAME" src="http://67.9.157.55:80/" noresize>
    	    <noframes>
    	       	<body>
               <h1>David Gray's People Finder</h1>
               Search 500mil people including the TX, CA, KY etc... Birth/Death/Marriage indexes and Texas Birth/Death/Delayed Books and more...<br>
    	   adoption,search,genealogy,archives,texas birth index,texas marraige index,texas divorce index,texas death index index,vital records,vital<br>
    	   <br>
    	   Click here to enter <a href="http://67.9.157.55:80/">http://67.9.157.55:80/</a>
               <hr>
    | Domain Name Registration and Domain Name Forwarding by <a href="http://www.mydomain.com">mydomain.com - Register your domain name</a>
            </body>
    	    </noframes>
    	</frameset>
    
    </html>
    That's what the WebBrowser1.Document control sees. There's no form in sight.

    Now, if you access the page by the redirect they have (their FRAME src or the link in their NOFRAMES section), your code will work as you want it to.

  10. #10
    Join Date
    Jan 2004
    Location
    TX, USA
    Posts
    347

    Re: Frustrated - Webbrowser1 !!!

    I have to be honest. I hardly know anything about HTML and barely can program VB but thru your suggestion, IT WORKED!!!!!

    Using the src value, these are the values I found on the login page.

    affUSER hidden
    user text
    pass password
    submit PROCEED

    The next page is the 'search parameter page' and it must also be in a frame because I used the same code and it worked also.

    affUSER hidden
    user text
    pass password
    submit PROCEED

    user hidden
    affUSER hidden
    LastName text
    FirstName text
    MiddleName text
    submit Search
    BirthDateMM select-one 00
    BirthDateDD select-one 00
    BirthDateYY select-one 0000
    ExactDobFlag hidden true
    LevelControl hidden 0
    Region hidden TxAll
    ZipCode hidden
    AllowBirthDateDD hidden 1
    AllowBirthDateMM hidden 1
    AllowBirthDateYY hidden 1
    AllowExactDobFlag hidden 1
    AllowFirstName hidden 1
    AllowLastName hidden 1
    AllowLevelControl hidden 1
    AllowMiddleName hidden 1
    AllowRegion hidden 1
    AllowZipCode hidden 0
    OtherName hidden
    PersonStreet hidden
    PersonNum hidden

    Now, will the src change with time AND is this normal HTML programming as used by this site?

    Your effort and enlightment is truly appreciated !

    Cathy
    Cathy
    Jan 2004 - NEWBIE to VB6
    Any and all help appreciated

  11. #11
    Join Date
    Nov 2005
    Location
    Omaha, Nebraska, USA
    Posts
    696

    Re: Frustrated - Webbrowser1 !!!

    Quote Originally Posted by nbCathy
    Now, will the src change with time
    If they want to change where the page is stored, then the SRC attribute for the FRAME can change.

    Quote Originally Posted by nbCathy
    is this normal HTML programming as used by this site?
    Frames are a normal part of HTML. While the intent of frames is generally to not require you to redownload navigation and header content while going from page to page on a site, that site used them to hide the URL of the page you were currently on (as you notice the SRC attribute for the FRAME points to an IP address and not a named website).

    Is it normal? I wouldn't think so, but if it can be done, it will, so you should expect to see some pages like that.

  12. #12
    Join Date
    Jan 2006
    Location
    Fox Lake, IL
    Posts
    15,007

    Re: [RESOLVED] Frustrated - Webbrowser1 !!!

    As soon as they detect that you are automating their form, is when they'll decide if and when they want to make changes. They have a pretty good system now. Just don't hit it 100 times in 20 minutes
    David

    CodeGuru Article: Bound Controls are Evil-VB6
    2013 Samples: MS CODE Samples

    CodeGuru Reviewer
    2006 Dell CSP
    2006, 2007 & 2008 MVP Visual Basic
    If your question has been answered satisfactorily, and it has been helpful, then, please, Rate this Post!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured