Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Read html using XMLHTTP

Posted on 2003-02-24
8
Medium Priority
?
516 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
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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

CTAs encourage people to do something specific to show interest in your company, product or service. Keep reading to learn why CTAs should always be thought of as extremely important, albeit small, sections of websites.
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…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month11 days, 6 hours left to enroll

571 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