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

2
  • 2
    possible duplicate of Extract text from "<p>" HTML tag Commented Jul 9, 2014 at 18:03
  • You can search the string for "meta content=" then capture the URL from the string from the index value returned. Commented Jul 9, 2014 at 18:05

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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 
                            }

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.