|
-
Apr 29th, 2006, 11:17 AM
#1
Thread Starter
Frenzied Member
Problem getting value between html tags
Hi all i have this application that loads html and it needs to search trough all the html and list the numbers between VALUE=" and "></td> .I mean i want to collect bold number :VALUE="3018"></td>.
My program what it does now it outputs like this with some extra things:
Code:
http://localhost/new/player.php?song=,"album.php?show_albums,"3018","3019","3020","3021"
but i want it to look like this this
Code:
http://localhost/new/player.php?song=3018,3019,3020,3021
i tried many things i could not remove the extra album.php?show_albums, and extra " from output url . I be happy if some one help me fix these problems.I bolded importent part.Thanks
Html code hast mane of this type of blocks
VB Code:
<tr>
<td align="center" scope="row">1</td>
<td align="center"><INPUT TYPE="Checkbox" NAME="song_id" ONCLICK="reviewSelection();" [B]VALUE="[/B]3018[B]"></td>[/B]
<td><a href="#" class="song_title" onclick="loadPlayer('3018');return false;"> my life
</a> </td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
my code:
VB Code:
Private Sub Command1_Click(Index As Integer)
Select Case Index
Case 0:
If txtURL.Text <> "" Then
RichTextBox1.Text = Inet1.OpenURL(txtURL.Text, icString)
End If
Case 1:
End
End Select
End Sub
Private Sub Command2_Click()
Dim sResult() As String, n As Long
If GetLine(RichTextBox1.Text, "[COLOR=Red]VALUE=[/COLOR]", " [COLOR=Red]></td>[/COLOR] ", sResult) Then
' Occurances were found and have been placed in the array
Text1.Text = "http://localhost/new/player.php?song"
For n = LBound(sResult) To UBound(sResult)
List1.AddItem sResult(n)
Text1.Text = Text1.Text & "[COLOR=Red],[/COLOR]" & Split(sResult(n), "=")(1)
Next n
'--------------- end of making url code
Else
' No occurances were found
End If
End Sub
Private Function GetLine(ByVal sText As String, ByVal sStart As String, ByVal sEnd As String, ByRef sArr() As String) As Boolean
Dim lPos As Long, lEnd As Long, lCount As Long, sTemp() As String
ReDim sTemp(100)
lPos = InStr(1, sText, sStart, vbTextCompare)
Do While lPos
lEnd = InStr(lPos, sText, sEnd, vbTextCompare)
If lEnd Then
'Remove & sEnd from the below line.
'sTemp(lCount) = Mid$(sText, lPos, lEnd - lPos) & sEnd
sTemp(lCount) = Mid$(sText, lPos, lEnd - lPos)
lPos = InStr(lEnd, sText, sStart, vbTextCompare)
Else
sTemp(lCount) = Mid$(sText, lPos)
lPos = 0
End If
lCount = lCount + 1
If lCount > UBound(sTemp) Then ReDim Preserve sTemp(100 + lCount)
Loop
If lCount > 0 Then
ReDim Preserve sTemp(lCount - 1)
sArr = sTemp
End If
GetLine = lCount
End Function
-
Apr 29th, 2006, 11:53 AM
#2
Re: Problem getting value between html tags
You can use string functions to achieve your goal:
VB Code:
Dim a As String, f As String
Dim b As Integer, e As Integer
a = "http://localhost/new/player.php?song=,""album.php?show_albums,""3018"",""3019"",""3020"",""3021"""
b = InStr(1, a, "=")
e = InStr(2, Mid$(a, b + 1, Len(a) - b), ",")
f = Left$(a, b) & Replace(Mid$(a, b + e + 1, Len(a) - b - e), """", "")
Debug.Print f
-
Apr 29th, 2006, 11:59 AM
#3
Thread Starter
Frenzied Member
Re: Problem getting value between html tags
thank u for u reply. But the integer values at the end of constructed url is not know before hand!!
I want my program to just get those intgers and put them in my constructed url as shown above:-( .
My program already collection the integer values for for some reason i gets some extra thing (may be there is similer pattern in my html VALUE="..... "></td> and it has album.php?show_albums). i tried to do like this by loooking at intgers between this pattern :
ONCLICK="reviewSelection();" VALUE="3027 "></td>
to make unique .The way i did it by replacing this line :
VB Code:
If GetLine(RichTextBox1.Text, "VALUE=", " ></td> ", sResult)
by
VB Code:
If GetLine(RichTextBox1.Text, "ONCLICK="reviewSelection();" VALUE=" ", " ></td> ", sResult)
but it gives me strange errors!!
In addition my constructed url contains this " between song ids and i do not how to remove thme from my constructed url!
I hope some one help me.Thanks
part of html blocks
VB Code:
................
<tr>
<td align="center" scope="row">10</td>
<td align="center"><INPUT TYPE="Checkbox" NAME="song_id" ONCLICK="reviewSelection();" VALUE="3027 "></td>
<td><a href="#" class="song_title" onclick="loadPlayer('3027');return false;">Shab bakhair
</a> </td>
<td align="center"> </td>
<td align="center"> </td>
</tr>
<tr>
.....
Last edited by tony007; Apr 29th, 2006 at 12:15 PM.
-
Apr 29th, 2006, 12:09 PM
#4
Re: Problem getting value between html tags
Try it like this instead:
VB Code:
If GetLine(RichTextBox1.Text, "VALUE=""", """></td>", sResult) Then
' Occurances were found and have been placed in the array
Text1.Text = "http://localhost/new/player.php?song="
For n = LBound(sResult) To UBound(sResult)
List1.AddItem sResult(n)
Text1.Text = Text1.Text & Split(sResult(n), "=""")(1) & IIf(n = UBound(sResult), vbNullString, ",")
Next n
-
Apr 29th, 2006, 12:38 PM
#5
Thread Starter
Frenzied Member
Re: Problem getting value between html tags
Thanks for u reply . i tried your code but it only removes the " from output url but still i get unwanted data inside my constructued url !!
My program what it does now it outputs like this with some extra things:
Code:
http://localhost/new/player.php?song=,"album.php?show_albums,"3018","3019","3020","3021"
but i want it to look like this this
Code:
http://localhost/new/player.php?song=3018,3019,3020,3021
My program already collects the integer values but for some reason i get some extra thing (may be there is similer pattern in my html VALUE="..... "></td> and it has album.php?show_albums).
i tried to do like this by loooking at intgers between this pattern :
ONCLICK="reviewSelection();" VALUE="3027 "></td>
to make unique .The way i did it by replacing this line :
VB Code:
If GetLine(RichTextBox1.Text, "VALUE=", " ></td> ", sResult)
by
VB Code:
If GetLine(RichTextBox1.Text, "[B]ONCLICK="reviewSelection();" VALUE= [/B] " ", " [B]></td>[/B] ", sResult)
but it gives me strange errors!!
-
Apr 29th, 2006, 12:59 PM
#6
Re: Problem getting value between html tags
Try:
VB Code:
If GetLine(Text2.Text, "reviewSelection();""" & " VALUE=""", """></td>", sResult) Then
-
Apr 30th, 2006, 11:16 AM
#7
Thread Starter
Frenzied Member
Re: Problem getting value between html tags
 Originally Posted by bushmobile
Try:
VB Code:
If GetLine(Text2.Text, "reviewSelection();""" & " VALUE=""", """></td>", sResult) Then
Many thanks for u reply. I have difficulty setting the search pattern criaterial .Could tell me how to find data shown in bold in the following pattern.
Code:
<option value="album.php?show_albums=oldies&JALSA=294c58d2c91828eae51d39707dd7e793;allow=NO;mohim=Download">Old Songs</option>
the bold part is changing i want to us them to construtt a full url.Thanks
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
|