|
-
Jun 5th, 2010, 06:26 AM
#1
Thread Starter
Lively Member
Last edited by _-Rs-_; Jun 6th, 2010 at 05:54 PM.
-
Jun 5th, 2010, 07:43 AM
#2
Re: Grab Links from Webpage/HTML source
RS
Try the InStr function.
What VB code do you have so far that "grabs" the text?
Where is the "grabbed text" put .... into an array? into something else?
Spoo
-
Jun 5th, 2010, 09:09 AM
#3
Frenzied Member
Re: Grab Links from Webpage/HTML source
Try, document.getelementsbytagname instead...
Good Luck
Option Explicit should not be an Option!
-
Jun 5th, 2010, 10:10 AM
#4
Thread Starter
Lively Member
Re: Grab Links from Webpage/HTML source
 Originally Posted by Spoo
RS
Try the InStr function.
What VB code do you have so far that "grabs" the text?
Where is the "grabbed text" put .... into an array? into something else?
Spoo
Bro first using the webbroswer i navigate to the website and then using same
ById().Click it clicks the browse button and it uploadeds the image after it's
uploaded all i want is to get the image link i even tried the bytagname but i
am still a noob so i may have not done it right so it didnt work then i tried to
grab the html and using Findtext and split() i wanted to grab the link from
between but problem was i am not even good at split i did
like this
vb Code:
Text2.Text = WebBrowser1.Document.documentelement.innerhtml
FindText = Split(Text2.Text, "[img]")
Text3.Text = Text3.Text & FindText(1)
but that code only split till [img] after that comes the image link but after
the image link there's still useless html codes
if you can give me example on how to grab link between 
that should do the trick 
Check your pm i sent you the site link
Last edited by _-Rs-_; Jun 5th, 2010 at 12:05 PM.
-
Jun 5th, 2010, 10:50 AM
#5
Re: Grab Links from Webpage/HTML source
RS
Maybe something like this:
Code:
Text2.Text = WebBrowser1.Document.documentelement.innerhtml
FindText = Split(Text2.Text, vbCrLf) ' uses vbCrLf instead of what you had
nn = UBound(FindText) ' num elements in array FindText
tagb = "<IMG" ' begin tag
tage = "</IMG" ' end tag
For ii = 0 to nn
b = InStr(UCase(FindText, tagb) ' beginning pos of tagb
e = InStr(UCase(FindText, tage) ' beginning pos of tage
If b > 0 Then ' only interested if have tagb in this given string
< code parse based on b and e >
End If
Next ii
Does this get you started?
FWIW, I noticed that tags seem to use "<" instead of "[".
EDIT:
As you may have guessed, I'm not too familiar with html codes.
Looks like I was wrong:
Replace: tagb = "<IMG"
.... with: tagb = "[IMG"
... and ditto with tage
Spoo
Last edited by Spoo; Jun 5th, 2010 at 11:19 AM.
-
Jun 5th, 2010, 12:23 PM
#6
Re: Grab Links from Webpage/HTML source
vb Code:
Dim X As Long, Y As Long
Dim sHtml As String
sHtml = LCase$(Text1.Text) 'cast to lower case
X = InStr(sHtml, "[img]")
Do While X
X = X + Len("[img]")
Y = InStr(X, sHtml, "[")
If X > 0 And Y > 0 Then
Debug.Print Mid$(sHtml, X, Y - X)
Else
Exit Do
End If
X = InStr(Y, sHtml, "[img]")
Loop
'returns
'http://images.com/thumbs/atob3iji.jpg
'http://images.com/images/atob3iji.jpg
Bon Appétit!
Last edited by FireXtol; Jun 5th, 2010 at 12:51 PM.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jun 5th, 2010, 12:25 PM
#7
Thread Starter
Lively Member
Re: Grab Links from Webpage/HTML source
 Originally Posted by Spoo
RS
Maybe something like this:
Code:
Text2.Text = WebBrowser1.Document.documentelement.innerhtml
FindText = Split(Text2.Text, vbCrLf) ' uses vbCrLf instead of what you had
nn = UBound(FindText) ' num elements in array FindText
tagb = "<IMG" ' begin tag
tage = "</IMG" ' end tag
For ii = 0 to nn
b = InStr(UCase(FindText, tagb) ' beginning pos of tagb
e = InStr(UCase(FindText, tage) ' beginning pos of tage
If b > 0 Then ' only interested if have tagb in this given string
< code parse based on b and e >
End If
Next ii
Does this get you started?
FWIW, I noticed that tags seem to use "<" instead of "[".
EDIT:
As you may have guessed, I'm not too familiar with html codes.
Looks like I was wrong:
Replace: tagb = "<IMG"
.... with: tagb = "[IMG"
... and ditto with tage
Spoo
Bro i added the code you gave but as you i am noob how do i show the
result in text box as u seen in my code in the end i added
vb Code:
Text3.Text = Text3.Text & FindText(1)
that shows the result sorry for the noob questions and one more problem is

Should it be like this
vb Code:
b = InStr(UCase, "FindText", tagb)
e = InStr(UCase, "FindText", tage)
once again sorry for the noob questions
-
Jun 5th, 2010, 12:29 PM
#8
Thread Starter
Lively Member
Re: Grab Links from Webpage/HTML source
 Originally Posted by FireXtol
I'm not sure why you'd use split....
Basically, what I suggest is(as far as built-in string procedures):
- x = Instr(strHtml, "[IMG]") 'get the char location of "[IMG]"(optionally use Y as the start)
- Ensure: x > 0
- Add the len("[IMG]") to x
- let x = that result of addition
- make y = Instr(x, strHtml, "[") 'find the closing brace, using X as the start
- Ensure: y > 0
- Use: strUrl = Mid$(strHtml, x, y - x - 1) to get the URL
- this process can be repeated specifying Y as the new start location for Instr
bro i am new leaner i have no idea what you said if you can give me a
example i wood appreciate it
Last edited by _-Rs-_; Jun 23rd, 2010 at 08:55 AM.
-
Jun 5th, 2010, 12:53 PM
#9
Re: Grab Links from Webpage/HTML source
 Originally Posted by _-Rs-_
bro i am noob new leaner i have no idea what you said if you can give me a
example i wood appreciate it 
I have modified the post with an example.
Software I use and highly recommend: Opera, Miranda IM, Peerblock, Winamp, Unlocker Assistant, JoyToKey, Virtual CloneDrive, Secunia PSI, ExplorerXP, GOM Player, Real Alternative, Quicktime Alternative,Sumatra PDF, and non-freeware: Photoshop and VB6( ).
My codebank: AllRGB, Rounded Rectangle(math), Binary Server, Buddy Paint, LoadPictureGDI+, System GUID/Volume Serial, HexToAsc, List all processes and their paths, quasiString matching
Strings(search, extraction, retrieval etc): Retrieve BBCode Link from HTML, RemoveBetween ()'s, strFindBetween(str1,str2), Insert text in HTML, HTML - GetSpanByID
-
Jun 5th, 2010, 01:16 PM
#10
Thread Starter
Lively Member
Re: Grab Links from Webpage/HTML source
-
Jun 5th, 2010, 01:26 PM
#11
Re: Grab Links from Webpage/HTML source
Resil
Let's look at your example HTML code in your OP
- <div id="mostrar_mas_enlaceview">
- <h2 id="mev">Thumbnail + <u>viewer</u> link</h2>
- <div class="ctninput">
- <div class="codex">HTML:</div><div class="inputshare">
- <input tabindex="1" value="<a href="[urlx]http://images.com/?v=atob3iji.jpg"><img[/urxl] src="[urlx]http://images.com/thumbs/atob3iji.jpg"[/urlx] border="0"></a>" onclick="this.focus();this.select();" />
- </div>
- </div>
- <div class="ctninput">
- <div class="codex">BBCode (Forums):</div><div class="inputshare">
- <input tabindex="2" value="[url=http://images.com/?v=atob3iji.jpg][imgx]http://images.com/thumbs/atob3iji.jpg[/imgx][/urlx]" onclick="this.focus();this.select();" />
- </div>
- </div>
- </div>
In the above, I have taken the first 13 lines of your example.
I purposely changed [img] to [imgx] and [/img] to [/imgx] so the text would display .. thus ignore, is just for demo purposes
So, if I understand your current question properly, you want to know how to extract http://images.com/thumbs/atob3iji.jpg from
array element 10.
Maybe something like this:
Code:
Text2.Text = WebBrowser1.Document.documentelement.innerhtml
FindText = Split(Text2.Text, vbCrLf) ' uses vbCrLf instead of what you had
nn = UBound(FindText) ' num elements in array FindText
tagb = "[IMG]" ' begin tag
tage = "[/IMG]"
Dim txtURL(100) as String
Dim begURL as Long
Dim lenURL as Long
Dim lenTAGb as Long
uu = 0
lenTAGb = 5 ' ie, length of [IMG]
For ii = 0 to nn
b = InStr(UCase(FindText(ii), tagb) ' = 70, or thereabouts
e = InStr(UCase(FindText(ii), tage) ' = 95, or thereabouts
If b > 0 Then ' only interested if have tagb in this given string
uu = uu + 1
begURL = b + lenTAGb
lenURL = e - b - lenTAGb
txtURL(uu) = Mid(FindText(ii), begURL, lenURL)
End If
Next ii
New statements shown in blue
Corrections to statements in my prior post shown in red
In our example case, you would get the following result:
txtURL(1) = "http://images.com/thumbs/atob3iji.jpg"
- I initialized uu (the "use" counter) at 100 -- this may be overkill.
- I think this is what you were asking about >> ie, the parsing bit
- If I'm wrong, let me know.
EDIT:
It took me so long to compose this post .. looks like you already
have resolved the issue.... oh well ...
EDIT-2:
Yes, sorry about that compile error you got. How silly of me... 
At least I caught it as I was preparing this rather lengthy post.
Spoo
Last edited by Spoo; Jun 5th, 2010 at 01:39 PM.
Reason: saw subsequent posts
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
|