Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

reading a webpage from within access

Status
Not open for further replies.

lamarw

MIS
Dec 18, 2002
223
US
Hi everyone,
Currently I am opening the webpage in a browser, 'selecting all' and pasting it into a text field which is working fine but it's clumsy. I parse through the text which includes field names and save the data to a table.
Is there a way from within access to open a webpage not using an external program and convert it's contents to text or is there a way to use an instance of iexplore.exe that allows me to peruse it. I am unaware of any controls that perform this function. Any help is very much appreciated!

Thanks,

Lamar
 
You can also create an IE object.

Code:
 Dim objIE as object
  Set objIE = CreateObject("InternetExplorer.Application") 
  objIE.Navigate "[URL unfurl="true"]http://www.google.com"[/URL] 

  While objIE.busy
    DoEvents 
  Wend

You can then use the document object to navigate the loaded page. For example if there's a particular tag with an ID that you want to view the contents of you can use:

Code:
objIE.Document.getElementByID("myID").innerText
 
Thanks MajP and joelflorendo for such a quick and meaningful response. I don't need to see the web page on the form I just want to manipulate it's data.
I'm going to try using the IE object first. I'm not real familiar in this area of coding. I tried simply cutting and pasting the first section, that seemed to work fine. It launched the browser and went to the web site to which I changed it. I then played around with the second line but got an error message: 'Object variable or With block variable not set' #91. Let me describe the actual process:

1. launch the browser as an object within the access code
2. login to the website (provide username and password|click)
3. drill down to the desired screen
4. when I get to the desired page copy the entire screen and save the text in the database (I'm imagining I can go back to my access form and 'click' executing the objIE object and get the entire page of text, I just don't know what to use)
5. parse the saved text into fields
6. go back to step three and repeat 3-6 until completed
7. close the browser
8. done

In step three there maybe several links that can be drilled into, however one click shows the page then back out to step three, select next link, show next page, save the entire text in another record and parse. Each page is it's own record.
I may need a little hand holding in this area with appropriate code, can you help in this?
 
Okay, I've tried both methods. It turns out that I need to view the web site in order to login and navigate to the needed page. Therefore, I'm trying the MSWebControl. One disadvantage is the lack of controls typically seen on a browser i.e. forward/back buttons. However, I can now navigate to the page I need to copy the text from. Using the innertext method does not produce the text I see on the page. When I debug.print the innertext I see 'Main' where I would expect to see a lot of text. I don't think it's using frames but if it is can I target a frame, say 'Main', with the innertext method? I'm not sure but when I look at the source it appears to be mostly XML.
 
joelflorendo (TechnicalUser) 11 Aug 09 17:38
check out this page:
You'll need to figure out what the IDs are of the tags you want to manipulate on the page and use the value property and click method to work with them.


Hi Joel and thanks for the reference. I went there but it was asking for credit card information and I didn't feel comfortable with that. You mentioned using the ID's. I want to take all the text as if selecting all and copy then paste into a text box. Actually, I was wondering if there was a kind of browser control that had 'object.Text' producing the text on the screen and object.Value rendering the underlying html/xml/... Have you heard of such a control? or do you have any other suggestions?

Lamar
 
actually, if the server is responding with xml, you might want to look at the msxml2.http library (
You can see on that page, they use it like:
Code:
Dim HttpReq As New MSXML2.XMLHTTP30
HttpReq.open "GET", "[URL unfurl="true"]http://localhost/books.xml",[/URL] False
HttpReq.send
MsgBox HttpReq.responseText

I recently used this library to query a webserver that required authentication so it's possible to use this to send credentials. It depends though on what variables the server you're trying to get data from is looking for. Not sure how familiar you are with html, but you'll have to examine the code of the login page to figure out what it needs...I know this isn't very specific help but it's different from case to case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top