473,804 Members | 3,196 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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("M icrosoft.XMLHTT P")
xmlhttp.setRequ estHeader "Content-type","text/txt"
xmlhttp.Open "get", "http://www.mysite.com/default.asp", False
xmlhttp.Send
text = xmlhttp.respons eText

dim fs, fname
set fs=Server.Creat eObject("Script ing.FileSystemO bject")
set fname=fs.Create TextFile("c:\te st.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 14564
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.CreateOb ject("Microsoft .XMLHTTP")
xmlhttp.Open "get", "http://www.mysite.com/default.asp", False
xmlhttp.Send
text = bts(xmlhttp.res ponseBody)
Set xmlhttp = nothing

dim fs, fname
set fs = Server.CreateOb ject("Scripting .FileSystemObje ct")
set fname=fs.Create TextFile("c:\te st.txt",true)
fname.Write(tex t)
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(a scb(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("M icrosoft.XMLHTT P")
xmlhttp.setRequ estHeader "Content-type","text/txt"
xmlhttp.Open "get", "http://www.mysite.com/default.asp", False
xmlhttp.Send
text = xmlhttp.respons eText

dim fs, fname
set fs=Server.Creat eObject("Script ing.FileSystemO bject")
set fname=fs.Create TextFile("c:\te st.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
3101
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 correct (They show up as ?). I tried following solutions to set the XML:lang or simple lang parameter in the div to el, but that didn't help.. Greek text in the surrounding page is showing up correct.. Here is the code i am using: The JS File
2
2529
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 want to load into a Microsoft.XMLHTTP ActiveX object and manipulate via javascript on the client side. Data is retreived from the server at the request of the javascript without having to reload the page. The Problem:
9
5586
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, using the same HTML/JS it always returns no data (xmlhttp.responseText is null). When I try to get headers using Mozilla or display the http status code I get some obscure exception in the javascript console that I've given up on searching for an...
1
4938
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, which is the file I am programmatically rewriting to elsewhere) gets changed. I am trying to use AJAX and JSON to do this. I have copied an example of using HttpRequest Object as the backbone of this from...
0
2753
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", "https://gateway.fedex.com:443/GatewayDC", false, "", ""); xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); xmlhttp.send(strXML);
4
8285
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 problems and this one is really getting to me... I have a page that allows you to Browse Authors. There are three drop down boxes that auto-populate via AJAX. I have a file which it calls and returns the dynamically built XML file in the boxes...
7
2155
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 reading the posts on this and other fora. I create an object using "xmlhttp = new XMLHttpRequest();", no problem. Then I have this script: function getContent(file){ if(file==""){ return; } xmlhttp.onReadyStateChange=stateChange();...
6
20524
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 Response.Write() as a JavaScript then using document.write() to update the page. <script language="javascript" type="text/javascript"> var xmlHttpTopologyReceiver = GetXmlHttpObject(); function GetXmlHttpObject() { var xmlHttp = null; try ...
0
9571
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10318
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10302
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10069
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5505
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5639
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2976
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.