tjgrindsted
asked on
HTTPWeb Request/Response
Hi i have this code, that shows a soccer match ranklist.
this code will the ranking list.
My question is, if i need to find a targ/name maybe like "c01 first" and i need to go 8 steps after the name and then show the text from that place to the next "<" how do i do that in asp.net.
In asphttp i know that i can do it like this:
Read=instr(ReadEnd,strResu lt,"c01 first")+8
ReadEnd=instr(Read,strResu lt,"<")
Team1=mid(strResult,Read,R eadEnd-Rea d)
but how do i do it in ASP.NET !?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)
Dim request As HttpWebRequest = CType(WebRequest.Create("http://www.dbu.dk/turneringer_og_resultater/resultatsoegning/position.aspx?poolid=135814"), HttpWebRequest)
Dim response As HttpWebResponse = CType(Request.GetResponse(), HttpWebResponse)
Dim reader As StreamReader = New StreamReader(response.GetResponseStream(),Encoding.GetEncoding("iso-8859-1"))
Dim input As String = reader.ReadToEnd()
Dim StartToken As String = "<div id="div2"></div>"
Dim EndToken As String = "<div class="PageUnionInfo" id="PageUnionInfo" style="margin-bottom:4px;">"
Dim ContentStartPosition As Integer = input.IndexOf(StartToken) + StartToken.Length
Dim ContentEndPosition As Integer = input.IndexOf(EndToken)
Dim Length As Integer = ContentEndPosition - ContentStartPosition
Dim Content As String = intput.Substring(ContentStartPosition, Length)
someLabel.Text = Content
End Sub
this code will the ranking list.
My question is, if i need to find a targ/name maybe like "c01 first" and i need to go 8 steps after the name and then show the text from that place to the next "<" how do i do that in asp.net.
In asphttp i know that i can do it like this:
Read=instr(ReadEnd,strResu
ReadEnd=instr(Read,strResu
Team1=mid(strResult,Read,R
but how do i do it in ASP.NET !?
ASKER
Hi i have looked at it 3 days now, but im stuck...
If i use this code
If u delete this part and the set someLable.Text = Output the i get the result table...
But when i add this part then i cant get the name Varde IF (1) from the output result
Hope u can help me !!
If i use this code
Imports System.Net
Imports System.IO
Imports System.Text
Partial Class eks2
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
Dim objRequest As HttpWebRequest = WebRequest.Create("http://www.dbu.dk/turneringer_og_resultater/resultatsoegning/position.aspx?poolid=135814")
Dim objResponse As HttpWebResponse = objRequest.GetResponse()
Dim Output As String = ""
Using reader = New StreamReader(objResponse.GetResponseStream(), Encoding.GetEncoding("iso-8859-1"))
Output = reader.ReadToEnd()
End Using
Output = Output.Substring(Output.IndexOf("<div id=""div2""") + 21)
Output = Output.Substring(0, Output.IndexOf("<div class=""PageUnionInfo"" id=""PageUnionInfo"" style=""margin-bottom:4px;"">"))
Dim ReadEnd As Integer = ""
Dim Read As Integer = ""
Dim strResult As String Output.ReadToEnd()
Read = strResult.IndexOf("poolid=", ReadEnd) + 15
ReadEnd = strResult.IndexOf("<", Read)
Dim Team1 As String = strResult.Substring(Read, ReadEnd - Read)
someLabel.Text = Team1
'It will writeout Varde IF (1)
End Sub
End Class
If u delete this part and the set someLable.Text = Output the i get the result table...
But when i add this part then i cant get the name Varde IF (1) from the output result
Dim ReadEnd As Integer = ""
Dim Read As Integer = ""
Dim strResult As String Output.ReadToEnd()
Read = strResult.IndexOf("poolid=", ReadEnd) + 15
ReadEnd = strResult.IndexOf("<", Read)
Dim Team1 As String = strResult.Substring(Read, ReadEnd - Read)
someLabel.Text = Team1
'It will writeout Varde IF (1)
Hope u can help me !!
ASKER
Someone that can help me here !?
ASKER
bump
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
post closed
ASKER
post closed
Dim Read As Integer = strResult.IndexOf("co1 first", ReadEnd) + 8
Dim ReadEnd As Integer = strResult.IndexOf("<", Read)
Dim Team1 As String = strResult.Substring(Read,R
Hope that helps.