Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic
WebZinc Now Has New .NET Version
Part 2: The Yin and Yang of WebZinc .NET
 More of this Feature
• Part 1: WebZinc Now Has New .NET Version
• Part 3: The Bottom Line
 
 Join the Discussion
Like it? Hate it?
Tell Us Why!
 
 Related Resources
• Karl Moore's Visual Basic .NET: The Tutorials
 
 Elsewhere on the Web
• WebZinc Home Page
• DeveloperFusion
Operated by James Crowley,
one of the fine folks at
White Cliff who bring
you WebZinc.
 


The best part of WebZinc .NET is that it has a really great object model that takes a lot of the grief out of finding the information you want on a web page programmatically. That last word is the key point. Web pages are designed to be viewed. It's easy to look at a web page, see the information you want, point to it, write it down or even memorize it. But try to get it into a program and it's a different story.

Karl wrote a "Whirlwind Tour" to introduce the WebZinc Help that shows you how to do it the WebZinc way. His example shows you how to get stock information from a Microsoft stock quote page. It's really pretty simple:


Dim MyText As String
With MyWebZinc.CurrentPage
   MyText = "Company: " & _
      .Tables(0).Rows(3).Cells(0).Text & _
      " Last Trade: " & _
      .Tables(0).Rows(3).Cells(3).Text & _
      " Change: " & _
      .Tables(0).Rows(3).Cells(9).Text
End With
MessageBox.Show(MyText)

Pages like the Microsoft stock quotation page don't change very often. That may be why Karl picked it as an example for the documentation. After all, it's created by a program, too (MS Excel - you can tell by viewing the source HTML).

The question is, how do you know that it's ".Tables(0).Rows(3).Cells(9).Text" and not ".Tables(0).Rows(4).Cells(9).Text" and will the information you need be in exactly the same place the next time you access the page? WebZinc's answer is that, "even if the site changes its design or adds new tables, WebZinc will automatically use its built-in intelligence to help you retrieve exactly the information you’re looking for."

To test this claim, I downloaded the Microsoft page and added a new column to the page in front of the columns extracted by the WebZinc program. Not to my surprise, it didn't extract the right information this time. It's not quite that automatic!

As I mentioned, long experience doing this sort of thing ('back in the day' when men were men and computers were room-sized monsters of wire and metal) helps me to appreciate what's necessary and important. When the page does change (and it eventually will), you need more power than just pointing "down three and over nine" in a table. Fortunately, WebZinc has the power! At the end of the "Whirlwind" introduction, Karl sketchs the things you're really going to have to know to use WebZinc successfully ... and at the same time, summarizes some of the 'power in reserve' that you get with WebZinc:

  • Learn about rules – Rules allow you to automatically filter out redundant information from the data you grab.
  • Learn about text processing – WebZinc .NET includes dozens of text editing features, enabling you to extract just what you want from a site.
  • Learn how to display the Web browser – This lets a user of your Windows application interact with a customized WebZinc .NET browser window.
  • Learn about XML and XSL processing – You can use WebZinc .NET to automatically load and process flexible XML files.
  • Learn about site management features – WebZinc .NET can be programmed to automate all the content on your site!

Although WebZinc is a great system, there's nothing it can do to eliminate the inherent complexity of today's web pages. I think I can predict with a fair degree of confidence that you're going to need a lot of the things on that list before even a great tool like WebZinc starts to work really well. Karl sort of admits this in the next page of his documentation when he says, "Sometimes the data you want to retrieve from a page isn’t neatly sitting inside a particular cell."

"Sometimes" ??? Funny guy, that Karl.

Anyway ... Karl said it would be easy to get basic information from a web page. Karl wouldn't lie, so I decided to try it! He used the BBC World News. I can't see why he picked that page when the much superior About Visual Basic home page is also available. So I upgraded his example in the documentation to use visualbasic.about.com.

In just a few minutes, I had crafted this program:

WebZinc Program Source

With this spectacular result:

WebZinc Program Result

Why even write a program, when you can go directly to the web page and read the same thing, you might ask. Well ... for one thing, you can see what my weekly article is about and avoid all the popup advertising!

Seriously, once you start treating the web like a business - and that's the name of the whole game these days - you're going to want to have a way of reading web pages with a program rather than copy-and-pasting information from the page. Individuals may not have a lot of use for WebZinc, but business users who are serious about the web for their bottom line certainly will.

Next page > The Bottom Line > Page 1, 2, 3

Explore Visual Basic

By Category

About.com Special Features

Build Your Own Website

Step-by-step advice on how to do everything from choosing a Web host to promoting your content. More >

Connect Your Home Computers

Easy ways to connect two computers for networking purposes. More >

Visual Basic

  1. Home
  2. Computing & Technology
  3. Visual Basic

©2009 About.com, a part of The New York Times Company.

All rights reserved.