?
Solved

Read html using XMLHTTP

Posted on 2003-02-24
8
Medium Priority
?
497 Views
Last Modified: 2008-02-01
I want to read a webpage using XMLHTTP and then create a text file and copy the html into the text file. Here is what I have although it's not working properly.

<%OPTION EXPLICIT%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Dim strUrl, objXmlHttp, strHTML
     strUrl = "http://www.msn.com"
Dim objFso, filetemp, filePath
filePath = "C:\someFolder\testData\Test.txt"    

Set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET", strUrl, False
objXmlHttp.send
strHTML = objXmlHttp.responseText  ''''<-- Here is where I copy the raw html into a text file '''''
Set objXmlHttp = Nothing

Set     objFso = Server.CreateObject("Scripting.FileSystemObject")
Set filetemp = objFso.CreateTextFile(filePath,True)

     filetemp.Write strHTML '''<-- Here is where I atempt to write it to a text file ''''
     filetemp.Close
     Set filetemp = Nothing
     Set objFso = Nothing
         
%>
</BODY>
</HTML>

The error I get is

Microsoft VBScript runtime error '800a0005'

Invalid procedure call or argument
0
Comment
Question by:CUTTHEMUSIC
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 4

Accepted Solution

by:
farzinm earned 160 total points
ID: 8010602
Your code worked perfectly for me what line are u getting the error?
0
 
LVL 2

Assisted Solution

by:communicate
communicate earned 480 total points
ID: 8010845
yeah, this is running fine on my computer as well...i get a text file with data from MSN downloaded on my C drive in the folder specified in the code...good stuff ;)
0
 
LVL 2

Assisted Solution

by:communicate
communicate earned 480 total points
ID: 8010858
i would check the permissions on the folder, check that the document is saved as plain ASCII/ANSI text not Unix text etc.
0
Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

 
LVL 1

Assisted Solution

by:NicolNghia
NicolNghia earned 160 total points
ID: 8013281
CUTTHEMUSIC,

Your code work OK with my test environment. However you should check again your test environment and your code:

1. The IUSR_<machinename> must have write access right to the folder in which you save the file.

2. The version of VBScript (VBS) provided with Active Server Pages currently does not have access to the values of constants defined by the Scripting object. As a result, you must provide a definition of the constants you wish to use in your scripts
 
cheer,
0
 
LVL 2

Assisted Solution

by:communicate
communicate earned 480 total points
ID: 8014240
you can also try commenting out the first statement:
<%OPTION EXPLICIT%> if its a problem with the variables, but it seems to be more to do with the permissions...quick test, give everyone full permission (just to test it out, then you can take away that permission)
0
 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 8017644
I got the code to work. But here is the funny thing. When I attempted to put other sites in the strUrl variable I got the message again. For Example http://www.realtor.com/default.asp?poe=realtor

<%OPTION EXPLICIT%>
<HTML>
<HEAD>
</HEAD>
<BODY>
<%
Dim strUrl, objXmlHttp, strHTML
    strUrl = "http://www.realtor.com/default.asp?poe=realtor"
Dim objFso, filetemp, filePath
filePath = "C:\someFolder\testData\Test.txt"    

Set objXmlHttp = Server.CreateObject("Microsoft.XMLHTTP")
objXmlHttp.open "GET", strUrl, False
objXmlHttp.send
strHTML = objXmlHttp.responseText  ''''<-- Here is where I copy the raw html into a text file '''''
Set objXmlHttp = Nothing

Set     objFso = Server.CreateObject("Scripting.FileSystemObject")
Set filetemp = objFso.CreateTextFile(filePath,True)

    filetemp.Write strHTML '''<-- Here is where I atempt to write it to a text file ''''
    filetemp.Close
    Set filetemp = Nothing
    Set objFso = Nothing
         
%>
</BODY>
</HTML>
0
 
LVL 2

Author Comment

by:CUTTHEMUSIC
ID: 8017741
Also, I checked the permissions and they are all set correctly
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 9350229
This question has been classified abandoned. I will make a recommendation to the
moderators on its resolution in a week or two. I appreciate any comments
that would help me to make a recommendation.

<note>
Unless it is clear to me that the question has been answered I will recommend delete.  It is possible that a Grade less than A will be given if no expert makes a case for an A grade. It is assumed that any participant not responding to this request is no longer interested in its final disposition.
</note>

If the user does not know how to close the question, the options are here:
http://www.experts-exchange.com/help/closing.jsp


Cd&

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Dramatic changes are revolutionizing how we build and use technology. Every company is automating, digitizing, and modernizing operations. We need a better, more connected way to work together as teams so we can harness the insights from our system…
Ready to get certified? Check out some courses that help you prepare for third-party exams.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question