Get Text from Web and Put in Table

del091

New member
Local time
Today, 05:23
Joined
Feb 20, 2012
Messages
2
Hello,

I appreciate any help that can be offered. Here is my scenario:

I am gathering a particular portion of text from a web query. The query is populated from a VBA Function and the use of SendKeys. (Sendkeys sometimes sends multiple characters and I am not sure why it does that either)

NOTE: I am using google as an example because the site I am pulling from is password protected. I do have full rights to the data I am collecting though.

Here are the steps I use:
Dim strLink As String
Dim blnOpening As Boolean
Dim strWebTitle As String
On Error GoTo err_handler

strLink = "weblink here"
strLink = "C:\Program Files\Internet Explorer\IEXPLORE.EXE " & strLink
strWebTitle = "Title of Website that appears on the Title bar when site is open"

Call Shell(strLink, vbMaximizedFocus)

blnOpening = True


'This is to wait for the web page to open
TWait = Time
TWait = DateAdd("s", 15, TWait)
Do Until TNow >= TWait
TNow = Time
Loop



'I read user defined function is better than using SendKeys
fSendKeys sSiteID()
fSendKeys ("{ENTER}")


' Waiting for the web page again
TWait = Time
TWait = DateAdd("s", 15, TWait)
Do Until TNow >= TWait
TNow = Time
Loop

Now I need to find a string of text, copy it, and place it in a table. I cannot seem to get the strSearchFor to find the text. I am currently utilizing IF Then Else statements to pop MsgBox and tell me if the text is found. It never is. The text always starts with “GW” and is 7 characters in total length.

Any assistance is appreciated. I am way out of my league here.
 
"weblink you provided"


This would work well if there were Element ID's in the HTML. Can you suggest something where they doe not exist? Below is a sample HTML I am working with, the text I am searching for starts with "DW".

<html>
<head>
<title>Site-Info View</title>
<STYLE TYPE="text/css">
input
{
font-family : Verdana, Arial, Helvetica, Sans-Serif;
font-size : 13px;
font-weight: bold;
}
</STYLE>
<script>
</script>
</head>
<body bgcolor="white">
<form name="siteinfocgiform">
<H4><a href="website" name="siteinfo" src="../images/siteinfo-title.gif" ALT="siteinfo" align="center" border="0"></a></H4>
<br>
<input type="hidden" name="resultinfo"
value="<BR>********************************************************************************<BR>* site-info v3.18
(June 2009) *<BR>**<BR>*Please report any issues to "email">* Select
Application/Software-->Your Tools-->Site Info
*<BR>********************************************************************************<BR><BR>~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<BR>~site-info
x176222~<BR>~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~<BR>OTS Service Type
Information:<BR>--------------------------------------------------------------------------------<BR>1: T1 Price
Protected<BR>Line Type: Unknown<BR>Line Speed: Unknown<BR>Internet Protocol:
Unknown<BR>Customer Indicator : N/A<BR><BR><BR>OTS Service Feature
Details:<BR>--------------------------------------------------------------------------------<BR><BR><BR><BR><BR>
Site info for x176222 - T1 Customer at PAO1:
<BR>============================================================================
====<BR>Cisco sub-interface Info
(x176222):<BR>--------------------------------------------------------------------------------<BR> T1 CUSTOMER on
DW8.PNN1, 4:4OC48X/ATM-NM-SC, 0:OC48c, ATM4/0.197 [DLCI<BR> 198] (subnet 172.211.131.9)
.Status: Active and monitoring - Cisco Comment: <BR><BR>Cascade Interface
Info:<BR>--------------------------------------------------------------------------------<

Thanks!
 
You need to get into the DOM - document object model, http://www.w3schools.com/jsref/default.asp

There is a bunch ways of finding what you need ..fx. .getElementByXXXX where XXXX can be various things. There are other method too.

Also there is a pitfall I just dumped into recently - just because the browser says it is no longer busy, that does not mean that the page has finished loading. Putting a small delay can ensure that the page finished loading .. alternatively one can search for a unique element at bottom of page and see if it exists.

BTW: What you are doing is called screen scraping. Plug this term into google when stuck.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom