473,403 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,403 software developers and data experts.

Write xmlhttp result to text file

cwl
I want to get the content of a webpage containing plain text and write
the content to a text file. My code looks like this:

Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.setRequestHeader "Content-type","text/txt"
xmlhttp.Open "get", "http://www.mysite.com/default.asp", False
xmlhttp.Send
text = xmlhttp.responseText

dim fs, fname
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set fname=fs.CreateTextFile("c:\test.txt",true)
fname.WriteLine(text)
fname.Close
set fname=nothing
set fs=nothing

The first and second part of the code runs fine if they are executed in
seperate files. So the text is retrieved and it's possible to write a
text file to the server.

But when they are combined in one file - which they of course have to
be - I'm prompted to logon on the server! And the file containing the
above script is suddenly inaccessible. I'm only able to delete it from
the webserver.

Does anyone have a clue why this happens?

The script runs on IIS 6.

Aug 8 '06 #1
1 14442
cwl
I solved it. It had to do with special characters in the retrieved
text. Had to convert the binary data to string.
Set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
xmlhttp.Open "get", "http://www.mysite.com/default.asp", False
xmlhttp.Send
text = bts(xmlhttp.responseBody)
Set xmlhttp = nothing

dim fs, fname
set fs = Server.CreateObject("Scripting.FileSystemObject")
set fname=fs.CreateTextFile("c:\test.txt",true)
fname.Write(text)
fname.Close
set fname=nothing
set fs=nothing

function bts(data)
'Converts binary data to string
sOut = ""
For i = 0 to UBound(data)
sOut = sOut & chrw(ascw(chr(ascb(midb(data,i+1,1)))))
Next
bts=sOut
end function


cw*@colon.dk skrev:
I want to get the content of a webpage containing plain text and write
the content to a text file. My code looks like this:

Set xmlhttp = CreateObject("Microsoft.XMLHTTP")
xmlhttp.setRequestHeader "Content-type","text/txt"
xmlhttp.Open "get", "http://www.mysite.com/default.asp", False
xmlhttp.Send
text = xmlhttp.responseText

dim fs, fname
set fs=Server.CreateObject("Scripting.FileSystemObject ")
set fname=fs.CreateTextFile("c:\test.txt",true)
fname.WriteLine(text)
fname.Close
set fname=nothing
set fs=nothing

The first and second part of the code runs fine if they are executed in
seperate files. So the text is retrieved and it's possible to write a
text file to the server.

But when they are combined in one file - which they of course have to
be - I'm prompted to logon on the server! And the file containing the
above script is suddenly inaccessible. I'm only able to delete it from
the webserver.

Does anyone have a clue why this happens?

The script runs on IIS 6.
Aug 9 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Nemlah | last post by:
Hello, I am working on a site which utilizes PHP/JS and the new found XMLHTTP frenzy to update dynamically. WHile the whole mechanism works beautifull, i can't get to display greek Characters...
2
by: mikeyjudkins | last post by:
Ive been banging my head on the wall for hours with this one, hopefully someone will know what Im doing wrong here :\ The Goal: I have an xml file that is generated on the fly via JSP which I...
9
by: fochie | last post by:
Greetings, I'm having a problem when I try to GET a file from my server via xmlhttp when using Mozilla. With IE I can get any type of file fine, get/display headers fine, etc. With Mozilla,...
1
by: Ike | last post by:
Ive copied an online example for writing out a php file, programmatically, then would like to re-display that data in a browswer window that automatically refreshes as the data file (getdata.php,...
0
by: SushiSean | last post by:
When executing the xmlhttp.send function to request shipper for available shipments (I send xml as string and receive result xml): XMLHTTP xmlhttp = new XMLHTTP(); xmlhttp.open("POST",...
4
by: sirjohnofthewest | last post by:
If I possessed the power to sway the mind of every user in the world to delete all forms of Internet Explorer I would die a happy man. Hi guys, I frequently visit this site to get answers to my...
7
by: Dan Beanweed | last post by:
I am experimenting with XMLHTTP in a personal website. If I can understand it I would like to use it in a SVG application at work. But I don't get what's going on with my code, especially after...
6
by: Bassem | last post by:
Hello everybody, I know it is an ordinary question, I tried a lot and searched but got nothing. I request another page (Default2.aspx) using JavaScript from (Default.aspx), get a response...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.