0

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

Ry-
  • 218,210
  • 55
  • 464
  • 476
Thomas Kowalski
  • 1,995
  • 4
  • 20
  • 42
  • 2
    possible duplicate of [Extract text from "

    " HTML tag](http://stackoverflow.com/questions/15876801/extract-text-from-p-html-tag)

    – Heinzi Jul 09 '14 at 18:03
  • You can search the string for "meta content=" then capture the URL from the string from the index value returned. – rheitzman Jul 09 '14 at 18:05

2 Answers2

2

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.

Aliden
  • 441
  • 1
  • 4
  • 15
0

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 
                            }
Fabio
  • 31,528
  • 4
  • 33
  • 72
China Syndrome
  • 953
  • 12
  • 24