Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
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/cham...izards.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 -- Mike Please post replies to newsgroup to benefit others Replace dead spam with ntl world to reply by email |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
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] Mike wrote: 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/cham...izards.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 |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
On Mon, 17 Nov 2003 at 07:59:47, Jake Marx (Jake Marx
) wrote: 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 -- Mike Please post replies to newsgroup to benefit others Replace dead spam with ntl world to reply by email |
#4
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
Hi Mike,
Mike wrote: 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] |
#5
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
On Tue, 18 Nov 2003 at 16:00:49, Jake Marx (Jake Marx
) wrote: 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 -- Mike Please post replies to newsgroup to benefit others Replace dead spam with ntl world to reply by email |
#6
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
On Mon, 17 Nov 2003 at 07:59:47, Jake Marx (Jake Marx
) wrote: 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 -- Mike Please post replies to newsgroup to benefit others Replace dead spam with ntl world to reply by email |
#7
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
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] Mike wrote: On Mon, 17 Nov 2003 at 07:59:47, Jake Marx (Jake Marx ) wrote: 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 |
#8
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
On Wed, 19 Nov 2003 at 07:08:11, Jake Marx (Jake Marx
) wrote: ?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 -- Mike Please post replies to newsgroup to benefit others Replace dead spam with ntl world to reply by email |
#9
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
On Tue, 18 Nov 2003 at 16:00:49, Jake Marx (Jake Marx
) wrote: 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-bi...d.pl?action=ac tion&word=anticonvulsive -- Mike Please post replies to newsgroup to benefit others Replace dead spam with ntl world to reply by email |
#10
Posted to microsoft.public.excel.programming
|
|||
|
|||
Browsing to URL and reading contents
On Thu, 20 Nov 2003 at 18:47:32, Mike (Mike )
wrote: 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 -- Mike Please post replies to newsgroup to benefit others Replace dead spam with ntl world to reply by email |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
need a calculation for browsing centre | Excel Worksheet Functions | |||
Reading contents | Excel Discussion (Misc queries) | |||
Browsing for a folder in "Look in:" | New Users to Excel | |||
Browsing for a folder in "Look in:" | Setting up and Configuration of Excel | |||
Browsing for a folder in "Look in:" | Excel Discussion (Misc queries) |