|
-
Dec 7th, 2001, 03:24 PM
#1
Thread Starter
Fanatic Member
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)
-
Dec 7th, 2001, 03:30 PM
#2
Thread Starter
Fanatic Member
what i'm basically trying to do is login to an account, but then download a file there with Inet control....
any help?
-
Dec 7th, 2001, 03:33 PM
#3
You should use the DOWNLOAD api to dowload stuff of the net
-
Dec 7th, 2001, 03:34 PM
#4
Thread Starter
Fanatic Member
i have better inet code so i can get kb/s and bytes transferred.
but it doesn't seem to download from second account.
-
Dec 7th, 2001, 03:52 PM
#5
Frenzied Member
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....
-
Dec 7th, 2001, 04:00 PM
#6
Thread Starter
Fanatic Member
so i want outerhtml not inner?
-
Dec 7th, 2001, 04:03 PM
#7
Thread Starter
Fanatic Member
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?
-
Dec 7th, 2001, 04:11 PM
#8
Thread Starter
Fanatic Member
well i just used the replace function to get rid of it.
Here is a little bit of what i am doing:
VB Code:
web1.Navigate ("http://" & txttype.Text & ".zzn.com")
Do Until web1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
With web1.Document
.All("loginname").Value = lstDwnUsers.Text
.All("loginpassword").Value = lstDwnPass.Text
.Forms(1).submit
End With
Do Until web1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
web1.Navigate ("http://" & txttype.Text & ".zzn.com/email/english/noframes/mailer/t_baseform.asp?whattodo=showfolder&toolbar=y&FolderID=Inbox")
Do Until web1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
txtHTML.Text = web1.Document.documentelement.outerHTML
sSrchLeft = "totalretard"
sSrchRight = lstDwnemail.Text
iPos1 = InStr(1, txtHTML.Text, sSrchLeft)
iPos2 = InStr(iPos1, txtHTML.Text, sSrchRight)
txtHTML.Text = Mid(txtHTML.Text, iPos1 + Len(sSrchLeft), iPos2 - (iPos1 + Len(sSrchLeft)))
txtHTML.Text = Right$(txtHTML.Text, 170)
sSrchLeft = "MessageID"
sSrchRight = "CurrentChunk"
iPos1 = InStr(1, txtHTML.Text, sSrchLeft)
iPos2 = InStr(iPos1, txtHTML.Text, sSrchRight)
txtHTML.Text = Mid(txtHTML.Text, iPos1 + Len(sSrchLeft), iPos2 - (iPos1 + Len(sSrchLeft)))
web1.Navigate ("http://" & txttype.Text & ".zzn.com/email/english/noframes/view/t_view.asp?MessageID" & txtHTML.Text & "CurrentChunk=1"), "C:\temp.html"
Do Until web1.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
txtHTML.Text = web1.Document.documentelement.outerHTML
sSrchLeft = "p_download"
sSrchRight = lstDownload.Text
iPos1 = InStr(1, txtHTML.Text, sSrchLeft)
iPos2 = InStr(iPos1, txtHTML.Text, sSrchRight)
txtHTML.Text = Mid(txtHTML.Text, iPos1 + Len(sSrchLeft), iPos2 - (iPos1 + Len(sSrchLeft)))
txtHTML.Text = Replace(txtHTML.Text, "amp;", "")
Inet1.URL = ("http://" & txttype.Text & ".zzn.com/email/english/noframes/view/p_download" & txtHTML.Text & lstDownload.Text)
-
Dec 7th, 2001, 04:12 PM
#9
Thread Starter
Fanatic Member
then to download i use:
VB Code:
Inet1.Execute , "get"
Private Sub Inet1_StateChanged(ByVal State As Integer)
Dim vtData As Variant
Dim strFileName As String
Dim lngLength As Long
Select Case State
Case icResponseCompleted
Dim bDone As Boolean: bDone = False
Dim tempArray() As Byte
strFileName = txtSavePath.Text & lstDownload.Text
Open strFileName For Binary Access Write As #1
vtData = Inet1.GetChunk(1024, icByteArray)
DoEvents
If Len(vtData) = 0 Then
bDone = True
End If
Do While Not bDone
Timer1.Enabled = True
tempArray = vtData
Put #1, , tempArray
vtData = Inet1.GetChunk(1024, icByteArray)
DoEvents
ProgressBar1.Value = lngLength
lngLength = lngLength + 1024 \ 1024
On Error Resume Next
ProgressBar1.Value = lngLength
lblBytes.Caption = lngLength & "kb" & " of " & lstSizeDwn.Text & "kb"
If S = 0 Then
Else
lblKB.Caption = lngLength \ S & "kb/s"
End If
If Len(vtData) = 0 Then
bDone = True
End If
Loop
Close #1
End Select
-
Dec 7th, 2001, 04:13 PM
#10
Thread Starter
Fanatic Member
I would appreciate it if you could help Bloodeye
-
Dec 7th, 2001, 04:22 PM
#11
Frenzied Member
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.
-
Dec 7th, 2001, 04:23 PM
#12
Thread Starter
Fanatic Member
I am downloading attachments from certain emails in the inbox.
How do i progrmatically click a link?
-
Dec 7th, 2001, 04:46 PM
#13
Frenzied Member
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:
Dim ImgElem As HTMLImg
Dim AnchorElem As HTMLAnchorElement
Public Sub Click_Object(objType As String, strCompare As String)
Select Case objType
Case "image"
For Each ImgElem In WebBrowser1.Document.images
If ImgElem.alt = strCompare Then
ImgElem.Click
Exit For
End If
Next
Case "anchor"
For Each AnchorElem In WebBrowser1.Document.links
'Debug.print AnchorElem.innerText
'Debug.print AnchorElem.outerText
If AnchorElem.innerText = strCompare Then
'If AnchorElem.outerText = strCompare Then
AnchorElem.Click
Exit For
End If
Next
Case "other"
End Select
End Sub
Usage:
VB Code:
Call Click_Object("image", "My Image")
Call Click_Object("anchor", "My link")
-
Dec 7th, 2001, 04:52 PM
#14
Frenzied Member
Here's another method to click links
VB Code:
Dim linkToclick As String
Dim rightlink As String
Dim i As Integer
linkToclick = "http://whatever.the.link.is.com"
For i = 0 To WebBrowser1.Document.links.length - 1
rightlink = WebBrowser1.Document.links(i).href
If rightlink = linkToclick Then
WebBrowser1.Document.links(i).click
Exit For
End If
Next
-
Dec 7th, 2001, 05:04 PM
#15
Thread Starter
Fanatic Member
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?
-
Dec 7th, 2001, 05:20 PM
#16
Frenzied Member
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?
-
Dec 7th, 2001, 05:23 PM
#17
Thread Starter
Fanatic Member
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
-
Dec 7th, 2001, 05:40 PM
#18
Frenzied Member
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.
-
Dec 7th, 2001, 05:50 PM
#19
Thread Starter
Fanatic Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|