O'Reilly logo

Microsoft® Visual Basic® .NET Programmer's Cookbook by Matthew MacDonald

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Retrieve a Single Piece of Information from a Web Page

Problem

You want to extract a single piece of information from a Web page.

Solution

Use the WebResponse class to retrieve the stream, copy it to a string, and use a regular expression.

Discussion

You can extract information from a Web stream in several ways. You could read through the stream, use methods of the String class such as IndexOf, or apply a regular expression. The latter of these—using a regular expression—is the most flexible and powerful.

The first step is to create a regular expression that filters out the information you need. recipe Parse a String Into Words provides several examples and a reference to basic regular expression syntax. For example, most Web pages include a text title ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required