Results 1 to 18 of 18

Thread: Webpage Source not reloading

  1. #1

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Webpage Source not reloading

    I am making a program that will automatically search for you on the internet in visual studios 2005 beta, i navigate to the page in my own webbrowser on my program well heres the code

    VB Code:
    1. j = AutoLogin.WebBrowser20.Document.All.Count
    2.             Do While i < j
    3.                 If AutoLogin.WebBrowser20.Document.All(i).TagName = "INPUT" Then
    4.                     k = AutoLogin.cmbSubscribe.SelectedIndex + 1
    5.                     If AutoLogin.WebBrowser20.Document.All(i).Name = "keywords" Then
    6.                         AutoLogin.WebBrowser20.Document.All(i).Focus()
    7.                         My.Computer.Keyboard.SendKeys(WordGet() & vbCrLf, True)
    8.                         AutoLogin.WebBrowser20.GoBack()
    9.                     End If
    10.                 End If
    11.                 i = i + 1
    12.             Loop

    the code enters the word into the textbar and presses enter. afterwhich it gos back to the main search page and is suposed to do it again. But the source cod for the website DOESN'T CHANGE! and when it loops again on the main page it skips over the input for the searchbox and then just ends. I was wondering how i could update the source code of the website in the program allowing me to search more than once.

    and btw im using a 2.4ghz xp home edition computer if that makes any difference.

  2. #2
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Webpage Source not reloading

    Welcome to the forums

    Please post all .NET questions in the VB.NET section.

    Regards your problem, if you explain what you need to do, I can help you with VB6 code, but not .NET. Sorry.

  3. #3

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    thx for the welcome! Im actually using vb6 to do this not .net. I dont really no .net coding so i stuck with vb6 but what im trying to do is have the program enter a word into a form entry and press esnter than do this all over agin.
    my problem is first when it navigates to a new page in the program the source code stays the same as it was on the initial page that i started with. when i go back to the main page that i started with the source codes the same but since i have already used the input command for that page it just skips over and doesnt see it... so i was wondering how in vb6 that the program reset the source code every time it navigates to a different page on that browser.

    thx messup000

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Webpage Source not reloading

    Im still not really sure what you mean be "resetting the source code". Every time you load a/the page the source code returned is different. Here how I get it:

    VB Code:
    1. WebBrowser20.Document.body.parentElement.innerHTML

    Looking at the original code you posted it seems you could do it via collections.

    You are looking for an input field named "keywords" right?

  5. #5

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    yes it is "keywords" but what i mean by resetting the source code is that once the program is running and the code goes through it enters a word into this input field then presses enter because the submit button is now highlighted. and there are only 2 inputs on the webpage "submit" and "keywords". so when i go to the webpage that has the search input box on it the program runs through again and only sees the input tag "submit" and not "keywords" anymore. but in theory the source code shouldnt the tag "keywords" be visible and also if i start from a different webpage and navigate to the page with the search box in it and run this code it will not even see the input tags because it only views the source code of the webpage that i started at. Does that help?
    also how would i do it via collections?

  6. #6
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Webpage Source not reloading

    I have no idea why it would work once and not subsequently, but heres how I would do it, using collections:

    VB Code:
    1. Dim objInputCol As IHTMLElementCollection
    2. Dim i As Long
    3.  
    4. Set objInputCol = WebBrowser20.Document.body.all("input")
    5.  
    6. ' Set Keywords
    7. objInputCol("keywords").innerText = "Insert your string here"
    8.  
    9. ' Submit
    10. objInputCol("submit").click

    I think that should work, I'm not sure cos my VB is broken right now and I can't check. If it doesn't work post any error messages and what bit of code is highlighted

  7. #7

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    K thx a BUNCH will try

    messup000

  8. #8

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    ok so i tried the code and it says that IHTMLElementCollection isnt defined so i changed it to HTMLElementColection

    after which it said that AutoLogin.WebBrowser20.Document.Body.All("Input")was an html element and couldnt be converted into an element collection.

    but i think that if i had a refenrence to IHTMLElementCollection it would recoginize the line of code AutoLogin.WebBrowser20.Document.Body.All("Input")

    and it might work? but i havent been coding for a very long time and was wondering if you knew the reference that would define IHTMLElementCollection.

    thx oh and also heres how i tried to fix it:

    VB Code:
    1. Do While i < j
    2.                 [U][B]objInputCol = AutoLogin.WebBrowser20.Document.Body.All("INPUT").All[/B][/U]
    3. 'The error is "null reference exception unhandled  object refernece not set to an instance of an object"
    4.  
    5.  
    6.                 ' Set Keywords
    7.                 objInputCol("keywords").InnerText = WordGet() & vbCrLf
    8.                 'If AutoLogin.WebBrowser20.Document.All(i).TagName = "INPUT" Then
    9.                 '    'k = AutoLogin.cmbSubscribe.SelectedIndex + 1
    10.                 '    Debug.Print(AutoLogin.WebBrowser20.Document.All(i).Name)
    11.                 '    If AutoLogin.WebBrowser20.Document.All(i).Name = "keywords" Then
    12.  
    13.                 '        AutoLogin.WebBrowser20.Document.All(i).Focus()
    14.                 '        My.Computer.Keyboard.SendKeys(WordGet() & vbCrLf, True)
    15.  
    16.                 '        AutoLogin.WebBrowser20.GoBack
    17.                 '    End If
    18.                 'End If
    19.                 i = i + 1
    20.             Loop

    I hope i dont sound too stupid im not a complete noob im just not very familiar with vb coding with html tags.
    Last edited by messup000; Jun 11th, 2005 at 01:56 PM.

  9. #9
    Member
    Join Date
    Jun 2005
    Posts
    61

    Re: Webpage Source not reloading

    heres the code i used for my ibuxer program just change the settings to yours.

    Code:
    Dim URL As String
    Dim flags As Long
    Dim targetframe As String
    Dim PostData() As Byte
    Dim headers As String
    Dim cname As String
    Dim cseparator As String * 1
    Dim codes() As String
    PostData = cname & "=" & codes(codey) & "&" & "source=12"
    flags = 0
    targetframe = ""
    PostData = StrConv(PostData, vbFromUnicode)
    WebBrowser1.Document.All("keywords").Value = codes(codey)
    WebBrowser1.Document.All("source").Value = "12" ' this is a list
    WebBrowser1.Document.All("Submit").Click

  10. #10

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    lol i was using ibux for testing just to get some extra bux! so once this is over do you have it loop?or do you have it close the browser after 45 seconds and open a whole new one? also what version of vb are you using? maybe vs2005? cause i think it might just be a problem in the beta programing at this point.

    thx messup000

  11. #11
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Webpage Source not reloading

    Sorry I should have said you need to add a reference to the Microsoft HTML Object Library (Project->References).

  12. #12

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    sok i have figured out how to do this!!! but im still having an error on the submit button .click it says raise event? maybe i should just copy the code to an older version of vb6? idk but anyways ill see what i can do. thx again

  13. #13
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Webpage Source not reloading

    What is the exact error message you get?
    Also what do you mean by "older version of vb6".

  14. #14

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    what i mean by older version is that i should run it off of the actual vb6 program and not visual studios 2005 because some of the language was switched around a little.

    once i put raiseevent infront of the submit.click line it says that objInputCol is not an event of Windows.App1.Module1 and this is the same if i replace it with autologin.WebBrowser20.Document.Body.All("submit").Click() or with WebBrowser20.Document.Body.All("submit").Click()

  15. #15
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: Webpage Source not reloading

    Bleargh, it doesn't work with .NET. It should however with VB6.

  16. #16

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    it might be that since the release of vs2005 beta 2they changed the timer function to vb.net they might just be slowly changing their vb programs into .net and that would make me sad! maybe they havnt gotten that far in their beta programing... hopefully

  17. #17

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    mmkay i talked to another person a little more about the .click problem its not that it doesnt work it is just that in vs2005 they changed the the name of the function. So i will look around in the help files for the right function

  18. #18

    Thread Starter
    Addicted Member messup000's Avatar
    Join Date
    Jun 2005
    Posts
    181

    Re: Webpage Source not reloading

    so im going to try and rewrite the program in the original vb6 and see if that will change anything, maybe wait for a more complete version of vs2005. but if anyone has anymore info on this topic plz speak up. same problem? i dont want to feel ALONE

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