codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:



Home » XML » Article

Pulling Data from Other Web pages with XMLHTTP

Article by:  Jeff Anderson  ( 1361 ) (3/16/2002)
Bookmark us now! Add to Favourites
Email a friend!Tell a friend
Sponsored by: FindMyHosting - Web Hosting Search
Summary: Using the little known (as yet) XMLHTTP object, part of the XML DOM Model, you can pull data from other web pages for manipulation or your own purposes.
Viewed: 46610 times Rating (21 votes): 
 4.3 out of 5
 Rate this Article  Read Comments  Post Comments


Using the little known (as yet) XMLHTTP object, part of the XML DOM Model, you can pull data from other web pages for manipulation or your own purposes. Until now, this involved using a COM component such as ASPHTTP, but with XMLHTTP you can do it with just a reasonably upto date version of IE.




 
 <%
  
  Dim objXMLHTTP, xml

  
  Set xml = Server.CreateObject("Microsoft.XMLHTTP")
  
  xml.Open "GET", "http://www.codetoad.com/", False
	
  ' Pull the data from the web page
  xml.Send

  
  Response.write "Here's the html we now have in our xml object"
  Response.write "<BR><BR><BR>"
  Response.Write "<xmp>"
  Response.Write xml.responseText
  Response.Write "</xmp>"
  Response.write "<BR><BR><BR>"
	Response.write " Now here's how the page looks:<BR><BR>"
  Response.Write xml.responseText
 
  
  Set xml = Nothing
%>


You can see an example of how this works here






CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums
Rate this article:     Poor Excellent
View highlighted Comments
User Comments on 'Pulling Data from Other Web pages with XMLHTTP'
Posted by :  Archive Import (David Rose) at 16:10 on Friday, November 01, 2002
I'm trying to find an example of this using a post (not a get) to do a form submission, returning authentication.
Posted by :  Archive Import (XML TESTER) at 15:08 on Wednesday, November 06, 2002
It is really good...But what should I do if I want to get source code after the form is submitted and results page is displayed
Posted by :  Archive Import (Raghuraman K P) at 05:54 on Saturday, November 09, 2002
This is a very useful code. But I would like to go a bit further by giving the url and then it should go to all the links in the url and store the web pages as xml

Posted by :  Archive Import (Rahul) at 05:44 on Saturday, December 07, 2002
How to pull HTML pages with different character set (ARABIC) with XMLHTTP?
Posted by :  Archive Import (Wael) at 13:54 on Sunday, February 16, 2003
How to pull Arabic character set text
Posted by :  Archive Import (mani) at 19:45 on Monday, May 05, 2003
can i get only few information retrive
from a web site.using the Xml
for example
p
Posted by :  Archive Import (Pooya) at 02:09 on Wednesday, May 28, 2003
Hi ,
When I try to read from an Unicode asp page with XMLHTTP , all the page contetnst Convert to "?" symbol .
please tell me how can i read UTF-8 Character from a page using XMLHTTP

please help me trough my email :
pooya_ma@yahoo.com

Tnx
Posted by :  Archive Import (Kasper) at 12:42 on Tuesday, June 03, 2003
Look at changing changing the code page
Posted by :  Archive Import (bharath) at 07:07 on Thursday, June 12, 2003
parsing the text obtained by xml.responsetext and get the different element datas?
Posted by :  Archive Import (Archy) at 14:29 on Tuesday, July 29, 2003
Problems with character set text or UTF-8 Character

Just try this

<%
Response.Buffer = True
Dim objXMLHTTP, xml
Set xml = Server.CreateObject("Microsoft.XMLHTTP")

xml.Open "GET", _
"http://www.elpais.es", _
False

xml.Send


' Add a header to give it a file name:
Response.AddHeader "ContentType", _
"text/html;c h a r s e t=UTF-8"

'c h a r s e t without blank spaces
'somethings wrong with this submit

' Binarywrite the bytes to the browser
Response.BinaryWrite xml.responseBody

Set xml = Nothing
%>
Posted by :  Archive Import (Paul Pinto) at 00:18 on Wednesday, July 30, 2003

With ref to the XMLHTTP object - I'm trying to get some XML data off a page that requires authentication - which is taken off a cookie that ought to be there already - and then redirects to the XML page. I'm having some problems when accessing the .responseText of the XMLHTTP object after the GET request - I seem to only get a load of Javascript from the first page. How do I make sure that the page is given enough time to redirect and then I get the final XML?

Thanks
Paul
Posted by :  Archive Import (Khalid) at 06:59 on Sunday, August 31, 2003
Yes, using charset=UTF-8 within the page would print out the Arabic text to the caller page correctly, but will not solve if a text was saved in an external file, for example a .txt file!!!

How would I be able to use the xmlhttp to open and get an Arabic text saved in a .txt file?

Thanks
Posted by :  gartarman at 17:51 on Friday, March 05, 2004
The code works great! I need help the images and links to the url's root. How can I correct so that they point to the right location. Plus, I am using SSI for a header and a footer will they remain if the links point to the right location

Thanks in advance,
gartarman
Posted by :  kajol at 01:53 on Thursday, October 14, 2004
Hi

your code is not working for the http://www.bizrate.com can you please fix the bug in it, because otherwise the code is good.

kajol
Posted by :  prakash at 02:36 on Monday, November 08, 2004
it not working for sweedish character...
how to pull the swedish character set....

regards
Prakash
Posted by :  dinesh at 01:43 on Tuesday, November 23, 2004
plz help me for this what should I do if I want to get source code after the form is submitted and results page is displayed
Posted by :  Screpper at 23:00 on Tuesday, November 30, 2004
here is example of GET query in russian language - working fine

Set oHTTP = CreateObject("Msxml2.XMLHTTP")
oHTTP.Open "GET","http://www.rambler.ru",False
oHTTP.Send

Set oRS = CreateObject("ADODB.Recordset")
oRS.Fields.Append "ru",200,100000
oRS.Open
oRS.AddNew
oRS(0).AppendChunk oHTTP.ResponseBody

Response.Write oRS(0)

Set oRS = Nothing
Set oHTTP = Nothing

I heard that ADODB.Recordset has dangerous hole and will be denied by patches, isn't it?
Posted by :  reynolda at 05:02 on Thursday, January 13, 2005
Anyone know how to convert this into a .NET project??


To post comments you need to become a member. If you are already a member, please log in .

 



RELATED ARTICLES
Display XML in tree format using Javascript
by Premshree Pillai
In this article, I present a XML based client-side JavaScript that reads data from an external XML file, traverses the XML data and displays the same in a tree format. I'll use the XMLDOM ActiveX object built into Microsoft Internet Explorer for the same.
XML and JavaScript Tutorial
by Premshree Pillai
This tutorial shows how we can use XML and client side JavaScript. We will see how we can display the contents of a XML file using JavaScript, accessing child elements, manipulating elements etc.
Pulling Data from Other Web pages with XMLHTTP
by Jeff Anderson
Using the little known (as yet) XMLHTTP object, part of the XML DOM Model, you can pull data from other web pages for manipulation or your own purposes.
XML Converter for MySQL database
by Rustem
MySQL has no native facilities for dealing with XML. This does not mean we are left out of the XML evolution. RustemSoft XML Converter has �MySQL to XML� support.
Using the XML Data Source Object
by Premshree Pillai
The XML Data Source Object (DSO) is a Microsoft ActiveX control built into Microsoft Internet Explorer 4+. Using this object, it is possible to extract content from an external XML file or XML data embedded in the HTML file into a HTML page. In this article, I'll explain how to include the XML DSO, extract content from an external XML file, extract XML data from XML data embedded in the webpage and manipulation using JavaScript
Creating An XML Newsfeed
by Jeff Anderson
A full explanation of how to take an XML newsfeed from moreover, amazon affiliates, google or any of the other current feed providers, and turn it into a display page using a little ASP.
XML Ticker using XML Data Source Object (DSO)
by Premshree Pillai
This news ticker shows an example of data binding using the XML DSO which is an ActiveX control built into Microsoft Internet Explorer.
Amazon Lite Web Service
by kokogiak.com
A complete XML web service allowing you to offer complete Amazon searches and disaply results on your site. A fantastic introduction to XML Web Services.
XML Ticker
by Premshree Pillai
This is an XML based JavaScript Ticker that can tick any number of messages. The ticker works with IE only. The ticker reads it's contents, i.e the ticker style, text to be displayed, the link for that particular message from a XML file.
Batch processing XML with XSLT 2.0
by Krunal Patel
What you need is an XML version of the directory listing. Then, you could use that XML file as the single input file to XSLT and process each file using XSLT. It would be wonderful if you could do the directory processing in XSLT directly. Unfortunately, with all the power of XSLT -- and particularly XSLT 2.0 -- the language still doesn't have directory operations.








Recent Forum Threads
• Re: sorting and Linked list
• Re: need help linked list
• Re: Help with arrays
• Re: Reading from a file
• Re: Why Use Method?
• Re: Help with a simple program
• Re: need help with quiz
• Re: Help with filesystem object & displaying in a table
• Re: Genetic Algorithm Help


Recent Articles
Multiple submit buttons with form validation
Understanding Hibernate ORM for Java/J2EE
HTTP screen-scraping and caching
a javascript calculator
A simple way to JTable
Java Native Interface (JNI)
Parsing Dynamic Layouts
MagicGrid
Caching With ASP.Net
Creating CSS Buttons


Site Survey
Help us serve you better. Take a five minute survey. Click here!

© Copyright codetoad.com 2001-2005