?
Solved

VB.ne t Excel Add-in autmatically download data from a web page

Posted on 2014-01-12
4
Medium Priority
?
277 Views
Last Modified: 2014-01-12
Hi

What VB.net code would I use to automatically download data from a web page into Excel?

Is this even possible?
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 70

Expert Comment

by:Éric Moreau
ID: 39774782
it greatly depends on which Web site it is.
0
 

Author Comment

by:Murray Brown
ID: 39774816
I want to download tourist information from a range of websites in South Africa. Is there a way to grab information from website pages?
0
 
LVL 40

Accepted Solution

by:
Jacques Bourgeois (James Burger) earned 2000 total points
ID: 39775039
After referencing System.Net in your project, you can download the pages with code like the following:

     Dim client As New System.Net.WebClient
     Dim page As String = client.DownloadString("http://www.<YourSite>/<YourPage>.html)

You will need to analyze the page html to find ways to identify the location of the data you are looking for. You can then use string methods on variable page to isolate portions of the page that contains what you need.

As an example, the following first looks in the page for the position of the text "Yearly sales " followed by a bold tag, and then retrieves the 6 characters following the tag to get the data. The 16 is the length of the text you were looking for.

     Dim position As Integer
     Dim data As String

     position = page.IndexOf("Yearly sales <b>") + 16
     data = page.Substring(position, 6)

Note that it won't work with all pages. In order to prevent the possibility of somebody downloading a page, changing the data and reposting it somewhere else with erroneous data, some pages contains an image instead of html text. In such a case, the only possible way to retrieve the data would be to send the image through OCR software to transform the page into text before doing the analysis.
0
 

Author Closing Comment

by:Murray Brown
ID: 39775140
Thanks very much. Appreciate the help
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video we outline the Physical Segments view of NetCrunch network monitor. By following this brief how-to video, you will be able to learn how NetCrunch visualizes your network, how granular is the information collected, as well as where to f…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month13 days, 3 hours left to enroll

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question