Browsing to URL and reading contents

  • Thread starter Thread starter Mike
  • Start date Start date
M

Mike

I am familiar with navigating to a URL and examining the text on a page,
but I want to be able to navigate here
http://www.chambersharrap.co.uk/chambers/wwizards/wwizards.py/main
put a word into the scrabble box, activate the arrow beside it, then
examine the results page that then follows to

There are other dictionary pages at this web page, but the word
validation is different and I need to validate against the scrabble box

Please can someone tell me how this is done
 
Hi Mike,

This should work for you:

Public Function gbCheckScrabbleWord(rsWord) As Boolean
Dim ie As InternetExplorer
Dim sURL As String
Dim sHeader As String
Dim bytPostData() As Byte

Set ie = New InternetExplorer

ie.Visible = False

sURL =
"http://www.chambersharrap.co.uk/chambers/wwizards/wwizards.py/main"
bytPostData = "sword=" & rsWord & ""

bytPostData = StrConv(bytPostData, vbFromUnicode)
sHeader = "Content-Type: " & "application/x-www-form-urlencoded" &
vbCrLf
ie.Navigate sURL, 0, , bytPostData, sHeader

Do Until Not ie.Busy And ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop

gbCheckScrabbleWord = InStr(1, ie.Document.body.innerhtml, "OSW ")

ie.Quit
Set ie = Nothing
End Function

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
Hi Mike,

This should work for you:

Public Function gbCheckScrabbleWord(rsWord) As Boolean
Dim ie As InternetExplorer
Dim sURL As String
Dim sHeader As String
Dim bytPostData() As Byte

Set ie = New InternetExplorer

ie.Visible = False

sURL =
"http://www.chambersharrap.co.uk/chambers/wwizards/wwizards.py/main"
bytPostData = "sword=" & rsWord & ""

bytPostData = StrConv(bytPostData, vbFromUnicode)
sHeader = "Content-Type: " & "application/x-www-form-urlencoded" &
vbCrLf
ie.Navigate sURL, 0, , bytPostData, sHeader

Do Until Not ie.Busy And ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop

gbCheckScrabbleWord = InStr(1, ie.Document.body.innerhtml, "OSW ")

ie.Quit
Set ie = Nothing
End Function
Cheers very much

Can you please explain the difference between the Busy and the
ReadyState attribute - isn't testing for both overkill

I know the IE window opens in the background as invisible, but are there
any API's for going to viewing contents of URL's without needing IE
 
Hi Mike,
Can you please explain the difference between the Busy and the
ReadyState attribute - isn't testing for both overkill

I don't know for sure. All I can say is that in some cases, using 1 or the
other seems to fail on my machine unless I put in Application.Wait or Sleep
statements.
I know the IE window opens in the background as invisible, but are
there any API's for going to viewing contents of URL's without
needing IE

You can use the MSXMLHTTP object:

Sub test()
Dim xml As XMLHTTP40

Set xml = New XMLHTTP40

xml.Open "POST", "http://www.chambersharrap.co.uk/" & _
"chambers/wwizards/wwizards.py/main"
xml.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xml.send "sword=test"
Debug.Print xml.responseText
Set xml = Nothing
End Sub

It does seem much faster, but I don't know what it's doing behind the
scenes. I assume it's using the core libraries IE does without actually
instantiating the IE application. I don't think it will be installed on all
machines, so you may have to distribute the library for your users.

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
You can use the MSXMLHTTP object:

Sub test()
Dim xml As XMLHTTP40

Set xml = New XMLHTTP40

xml.Open "POST", "http://www.chambersharrap.co.uk/" & _
"chambers/wwizards/wwizards.py/main"
xml.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xml.send "sword=test"
Debug.Print xml.responseText
Set xml = Nothing
End Sub

It does seem much faster, but I don't know what it's doing behind the
scenes. I assume it's using the core libraries IE does without actually
instantiating the IE application. I don't think it will be installed on all
machines, so you may have to distribute the library for your users.
Jake - you are a star

It needs a slight bit of tweaking in the middle before I check
responseText and I've had to use version 3.0 with Office 2000
 
Do Until Not ie.Busy And ie.ReadyState = READYSTATE_COMPLETE
DoEvents
Loop
Is it possible to tell me the values and names of all the READYSTATE_
constants. I've tried loading my Office CD-ROM, but it just plays the
windows tune and doesn't bring up the dialogue box

It's just a problem with that CD (or something with Office on my hard
drive) as other software is fine

This would be a big help please
 
Hi Mike,

?READYSTATE_COMPLETE
4
?READYSTATE_INTERACTIVE
3
?READYSTATE_LOADED
2
?READYSTATE_LOADING
1
?READYSTATE_UNINITIALIZED
0

I forgot to mention in the previous posts, but if you add a reference to
Microsoft Internet Controls, these constants will be defined for you (as
well as the InternetExplorer class).

--
Regards,

Jake Marx
MS MVP - Excel
www.longhead.com

[please keep replies in the newsgroup - email address unmonitored]
 
?READYSTATE_COMPLETE
4
?READYSTATE_INTERACTIVE
3
?READYSTATE_LOADED
2
?READYSTATE_LOADING
1
?READYSTATE_UNINITIALIZED
0
Many thanks

I forgot to mention in the previous posts, but if you add a reference to
Microsoft Internet Controls, these constants will be defined for you (as
well as the InternetExplorer class).
No worries - I'd worked that one out. Took a little longer to work out
what reference to include for the XML stuff though
 
You can use the MSXMLHTTP object:

Sub test()
Dim xml As XMLHTTP40

Set xml = New XMLHTTP40

xml.Open "POST", "http://www.chambersharrap.co.uk/" & _
"chambers/wwizards/wwizards.py/main"
xml.setRequestHeader "Content-Type",
"application/x-www-form-urlencoded"
xml.send "sword=test"
Debug.Print xml.responseText
Set xml = Nothing
End Sub
How would I do it for this one - used the same theory, but responseText
does not reflect the "yes!" or "not a word" (even when I do wait for a
ready status)


<http://www.mattelscrabble.com/cgi-bin/chambers/scrabbleword.pl?action=ac
tion&word=anticonvulsive>
 
How would I do it for this one - used the same theory, but responseText
does not reflect the "yes!" or "not a word" (even when I do wait for a
ready status)
Sorry my fault - I was combining the whole URL into the Open with "" for
the Send
 
Back
Top