Reputation: 2184
I hope someone will be able to help me in my quest. I'm trying to get a part of a string. But actually an exemple is better than a long explanation.
a long part here
what I want :D
another long part
Ok this is not very precise... You might say it's easy but... no. I don't know the length of the first part, and neither of the second. I'm not sure if I know the middle-string's length but I know I can recognise it this way :
HTML CODE
<meta content="http://a.constant/length/url/here/2048.jpg" property="og:image" />
HTML CODE AGAIN
How could I get only the URL or at least the line I need ?
Thank you in advance,
Thomas
Upvotes: 0
Views: 85
Reputation: 993
I have not done this with aspx file but with text files. You can use link and read all lines and then assign the string to an annonymous class
Dim Lists = From line In System.IO.File.ReadAllLines(sFilePath & "Page.ASPX").AsParallel()
Where line.length > 0
Select New With {
.IMAGEFILE = lineline.substring(lineline.IndexOf("http"),
lineline.IndexOf(".img>")).Trim
}
Upvotes: 0
Reputation: 451
This might not be the most efficient way to do it, but if you only need one line, you could read in each line, and then check for the <meta content
substring. Once you find the line, you need, you could get the URL by splitting the string with quotes as a delimiter and only looking at the second substring.
Dim substrings as String()
Dim lineIWant as String()
Dim whatIactuallyWant as String()
substrings = Split(lineIwant,"""")
whatIactuallyWant = substrings(1)
The crazy quotes are to get the quote character to go through.
Upvotes: 2