Results 1 to 19 of 19

Thread: Log In....And Download

  1. #1

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909

    Log In....And Download

    Okay i have a program and it uses the inet control and the webbrowser control.

    Here is the scenario:

    I use web1 to naviaget to a login page, It enters info and submits, I have web1 navigate to a certain page with a file link on it.

    When i get there i download the html source code and find the url for the file.

    Then i use inet to download this link.

    Now next time i login to a different account right after i'm done with the first account, it logs in but won't download the file?

    Why would this happen?

    (hope this partially makes sense)

  2. #2

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    what i'm basically trying to do is login to an account, but then download a file there with Inet control....

    any help?

  3. #3
    DaoK
    Guest
    You should use the DOWNLOAD api to dowload stuff of the net

  4. #4

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    i have better inet code so i can get kb/s and bytes transferred.

    but it doesn't seem to download from second account.

  5. #5
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    Hmmmm...difficult to say without seeing everything involved. One thing you don't have to do is download the HTML source code because if you have Navigated to it with the WebBrowser Control, then you can just retrieve the HTML source code by using "outerhtml".....something like this.

    Code:
    Dim sHtmlSource as String
    sHtmlSource = WebBrowser1.Document.documentElement.outerHtml
    If you want I can take a look at it for you....

  6. #6

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    so i want outerhtml not inner?

  7. #7

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    btw, when i use inner or outer i get this stupid thing in the url i am extracting:

    amp;

    what is that?


    Should look like this:

    %AB%A2%A3%A2%AB%AA%A3%A9&MessageID=13&AttachmentID=2

    but i get

    %AB%A2%A3%A2%AB%AA%A3%A9& and then i get amp; between then MessageID=13& and then amp; then AttachmentID=2

    why?

  8. #8

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    well i just used the replace function to get rid of it.

    Here is a little bit of what i am doing:

    VB Code:
    1. web1.Navigate ("http://" & txttype.Text & ".zzn.com")
    2.  
    3. Do Until web1.ReadyState = READYSTATE_COMPLETE
    4. DoEvents
    5. Loop
    6.  
    7.  
    8.    
    9. With web1.Document
    10.                 .All("loginname").Value = lstDwnUsers.Text
    11.                 .All("loginpassword").Value = lstDwnPass.Text
    12.                 .Forms(1).submit
    13.             End With
    14.  
    15.  
    16.  
    17.     Do Until web1.ReadyState = READYSTATE_COMPLETE
    18.     DoEvents
    19.     Loop
    20.  
    21.  
    22.     web1.Navigate ("http://" & txttype.Text & ".zzn.com/email/english/noframes/mailer/t_baseform.asp?whattodo=showfolder&toolbar=y&FolderID=Inbox")
    23.    
    24.    
    25.     Do Until web1.ReadyState = READYSTATE_COMPLETE
    26.     DoEvents
    27.     Loop
    28.  
    29.     txtHTML.Text = web1.Document.documentelement.outerHTML
    30.  
    31.     sSrchLeft = "totalretard"
    32.     sSrchRight = lstDwnemail.Text
    33.  
    34.     iPos1 = InStr(1, txtHTML.Text, sSrchLeft)
    35.     iPos2 = InStr(iPos1, txtHTML.Text, sSrchRight)
    36.  
    37.     txtHTML.Text = Mid(txtHTML.Text, iPos1 + Len(sSrchLeft), iPos2 - (iPos1 + Len(sSrchLeft)))
    38.    
    39.     txtHTML.Text = Right$(txtHTML.Text, 170)
    40.  
    41.     sSrchLeft = "MessageID"
    42.     sSrchRight = "CurrentChunk"
    43.    
    44.     iPos1 = InStr(1, txtHTML.Text, sSrchLeft)
    45.     iPos2 = InStr(iPos1, txtHTML.Text, sSrchRight)
    46.    
    47.     txtHTML.Text = Mid(txtHTML.Text, iPos1 + Len(sSrchLeft), iPos2 - (iPos1 + Len(sSrchLeft)))
    48.  
    49.    
    50.    
    51.     web1.Navigate ("http://" & txttype.Text & ".zzn.com/email/english/noframes/view/t_view.asp?MessageID" & txtHTML.Text & "CurrentChunk=1"), "C:\temp.html"
    52.    
    53.  
    54.     Do Until web1.ReadyState = READYSTATE_COMPLETE
    55.     DoEvents
    56.     Loop
    57.  
    58.     txtHTML.Text = web1.Document.documentelement.outerHTML
    59.    
    60.    
    61.  
    62.     sSrchLeft = "p_download"
    63.     sSrchRight = lstDownload.Text
    64.    
    65.     iPos1 = InStr(1, txtHTML.Text, sSrchLeft)
    66.     iPos2 = InStr(iPos1, txtHTML.Text, sSrchRight)
    67.    
    68.     txtHTML.Text = Mid(txtHTML.Text, iPos1 + Len(sSrchLeft), iPos2 - (iPos1 + Len(sSrchLeft)))
    69.    
    70.     txtHTML.Text = Replace(txtHTML.Text, "amp;", "")
    71.    
    72.     Inet1.URL = ("http://" & txttype.Text & ".zzn.com/email/english/noframes/view/p_download" & txtHTML.Text & lstDownload.Text)

  9. #9

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    then to download i use:

    VB Code:
    1. Inet1.Execute , "get"
    2.  
    3. Private Sub Inet1_StateChanged(ByVal State As Integer)
    4. Dim vtData As Variant
    5. Dim strFileName As String
    6. Dim lngLength As Long
    7.  
    8. Select Case State
    9. Case icResponseCompleted
    10. Dim bDone As Boolean: bDone = False
    11. Dim tempArray() As Byte
    12.  
    13. strFileName = txtSavePath.Text & lstDownload.Text
    14. Open strFileName For Binary Access Write As #1
    15. vtData = Inet1.GetChunk(1024, icByteArray)
    16. DoEvents
    17. If Len(vtData) = 0 Then
    18. bDone = True
    19. End If
    20.  
    21. Do While Not bDone
    22. Timer1.Enabled = True
    23. tempArray = vtData
    24. Put #1, , tempArray
    25.  
    26. vtData = Inet1.GetChunk(1024, icByteArray)
    27. DoEvents
    28. ProgressBar1.Value = lngLength
    29. lngLength = lngLength + 1024 \ 1024
    30. On Error Resume Next
    31. ProgressBar1.Value = lngLength
    32. lblBytes.Caption = lngLength & "kb" & " of " & lstSizeDwn.Text & "kb"
    33. If S = 0 Then
    34. Else
    35. lblKB.Caption = lngLength \ S & "kb/s"
    36. End If
    37. If Len(vtData) = 0 Then
    38. bDone = True
    39. End If
    40. Loop
    41.  
    42. Close #1
    43. End Select

  10. #10

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    I would appreciate it if you could help Bloodeye

  11. #11
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    The site looks to be some kinds of Email Service.

    I see you do a search through the HTML source code. What is it that your downloading. It looks like you are navigating to URL's based upon your search through the HTML source. Aren't there just links that you could programatically click instead of doing it this way?

    I'm not sure this is the problem.....just trying to figure out what it is that your doing.

  12. #12

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    I am downloading attachments from certain emails in the inbox.

    How do i progrmatically click a link?

  13. #13
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    Something like:
    web1.Document.links(7).Click
    7 would be the seventh link on that page.

    OR
    Here's some code for a Sub....you may have to clean it up a bit for what you need.
    VB Code:
    1. Dim ImgElem As HTMLImg
    2. Dim AnchorElem As HTMLAnchorElement
    3.  
    4. Public Sub Click_Object(objType As String, strCompare As String)
    5.  
    6. Select Case objType
    7.      
    8.     Case "image"
    9.          For Each ImgElem In WebBrowser1.Document.images
    10.          If ImgElem.alt = strCompare Then
    11.              ImgElem.Click
    12.              Exit For
    13.          End If
    14.          Next
    15.     Case "anchor"
    16.          For Each AnchorElem In WebBrowser1.Document.links
    17.          'Debug.print AnchorElem.innerText
    18.          'Debug.print AnchorElem.outerText
    19.          If AnchorElem.innerText = strCompare Then
    20.          'If AnchorElem.outerText = strCompare Then
    21.              AnchorElem.Click
    22.              Exit For
    23.          End If
    24.          Next
    25.     Case "other"
    26.  
    27. End Select
    28.  
    29. End Sub

    Usage:
    VB Code:
    1. Call Click_Object("image", "My Image")
    2. Call Click_Object("anchor", "My link")

  14. #14
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    Here's another method to click links

    VB Code:
    1. Dim linkToclick As String
    2. Dim rightlink As String
    3. Dim i As Integer
    4.  
    5. linkToclick = "http://whatever.the.link.is.com"
    6.  
    7. For i = 0 To WebBrowser1.Document.links.length - 1
    8.     rightlink = WebBrowser1.Document.links(i).href
    9.     If rightlink = linkToclick Then
    10.         WebBrowser1.Document.links(i).click
    11.         Exit For
    12.     End If
    13. Next

  15. #15

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    the link changes a lot so it would be hard to do that

    but i still don't know why it doesn't download from a second account after i download from the first one.

    is there some way to clear inet and webbrowser?

  16. #16
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    The only thing that enters my mind is that maybe when it goes to navigate to a particular link it get's everything from the cache, because that page is already in the cache.

    Try this: Have it go to the First Account, and do it's thing. Then clean out the cache, and see if it works on the Second Account.

    BTW: When you save a file, are you saving the files with different names?

  17. #17

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    yes i am giving each one a different file name when i save

    Also i was thinking if i made it navigate Not reading from cache like this

    Call web1.Navigate("http://" & txttype.Text & ".zzn.com", 4)

    that us suppose to make it not read from the cache accroding to the link you gave in that other post, i dunno if it will work.

    See the funny thing is it works okay on my computer but not on my friends

    I dunno what the problem could be

  18. #18
    Frenzied Member
    Join Date
    Mar 2001
    Location
    You are HERE •™
    Posts
    1,300
    If I remember right, having it not read from the cache doesn't work.
    If I were you I would put in a bunch of Message Boxes after every procedure, and then have your friend try it out.Then when
    the program cuts out on your friend, you will know where in the
    code that it is breaking down at. You could also create a log file
    based on this, so you would know where the program wasn't
    working.

  19. #19

    Thread Starter
    Fanatic Member stickman373's Avatar
    Join Date
    Mar 2001
    Location
    MA
    Posts
    909
    okay, i will get back to u after he uses it with message boxes everywhere

    Thanks so far!

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