[AccessD] Searching the Web

MartyConnelly martyconnelly at shaw.ca
Mon Feb 10 23:26:00 CST 2003


The code below will search for engineers in ohio
If the html string returned was XHTML compliant you could quickly parse
through the xml dom but unfortunately it isn't totally compliant.
So you will have to parse the relavant data out of the html string or 
saved file. maybe via RegExp.
if familiar with regular expressions or by instr function.
for significant data such as

<TR>
<TD ><A HREF="ReqDescr.asp?v_ReqNbr=104447&company=BCO">
<font size="-1"><B>Principal Research Scientist</B></font></TD>
<TD ALIGN="CENTER"><font size="-1">Columbus, OH</font></TD>
<TD ALIGN="CENTER"><font size="-1">1/6/2003</font></TD>
<TD ALIGN="CENTER"><font size="-1"> 104447</font></TD>
</TR>


Public Sub testBattelle()
'set reference to MS XML 3.0 at least

Dim objHTTP As New MSXML2.XMLHTTP

Dim strWebPage As String


'On Error Resume Next
'Retrieve Web Page

strWebPage = "http://web.battelle.org/jobs/textsearch.asp"

objHTTP.Open "POST", strWebPage, False

objHTTP.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

Dim strlogin As String

'guess you will need urlencode routine to replace spaces by %20 etc
strlogin = 
"?Form1=Search&value=Engineer%20AND%20(Columbus%20OR%20Cleveland)"
Debug.Print strlogin

objHTTP.send (strlogin)

Debug.Print objHTTP.readyState

'Check status of page

If Err.Number Or objHTTP.Status <> "200" Then

MsgBox Err.Number & Err.Description & vbCrLf & objHTTP.Status & " - " & 
objHTTP.statusText

'Exit Sub
End If


Dim strFileNameT As String
strFileNameT = "c:\Robin\"
strFileNameT = strFileNameT & Format(Now, "yyyymmddhhmmss") & ".html"
WriteFile strFileNameT, objHTTP.responseText

' objHTTP.responseXML
' look at the response
Debug.Print objHTTP.getAllResponseHeaders
Debug.Print objHTTP.Status & "-" & objHTTP.statusText
Debug.Print objHTTP.responseText

'Pass Response back from Server

End Sub
Public Sub WriteFile(ByVal sFileName As String, ByVal sContents As String)
' Dump XML String to File for debugging
Dim fhFile As Integer
fhFile = FreeFile
' Debug.Print "Length of string=" & Len(sContents)
Open sFileName For Output As #fhFile
Print #fhFile, sContents;
Close #fhFile
Debug.Print "Out File" & sFileName
End Sub


John Ruff wrote:

> This is a repost.
>
> I've been asked if it is possible for an Access program to 
> automatically go to a website, enter some search criteria, and log the 
> results into the database. As an example,
>
> The program would automatically go to 
> http://web.battelle.org/jobs/textsearch.asp, enter the key word, such 
> as "Access", click the Search button, and log all the Jobs found into 
> the Access program.
>
> I've used the Windows Task Scheduler to automatically start databases 
> that would compile data from other sources such as Oracle, ftp files, 
> etc, but I haven't a clue how to be able to automatically gather the 
> data in a scenario such as I've provided above.
>
> If anyone has done such a project, or knows how to tackle such a 
> project, could they please provide some guidelines and advice.
>
>
> John V. Ruff – The Eternal Optimist J
>
> “Commit to the Lord whatever you do,
> and your plans will succeed.” Proverbs 16:3
>
>





More information about the AccessD mailing list