Jump to content

Sky Slate Blueberry Blackcurrant Watermelon Strawberry Orange Banana Apple Emerald Chocolate
Photo

object.ResponseText error


  • Please log in to reply
4 replies to this topic
Im4everlast
  • Members
  • 4 posts
  • Last active: Feb 15 2014 04:03 PM
  • Joined: 28 Jan 2013

Why is ResponseText returning an error only on this website and not on others? How can this be fixed? 

 

Script:

#SingleInstance,Force
url=http://mangafox.me ;<-- Does not work | Works --> http//google.com, http://www.autohotkey.com, ...
Gui,Add,Edit,w800 h500 -Wrap,% URLDownloadToVar(url)
Gui,show,
return
URLDownloadToVar(url){
	hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
	hObject.Open("GET",url)
	hObject.Send()
	return hObject.ResponseText
}

Error:

<stderr>:
Error:  0x80070459 - No mapping for the Unicode character exists in the target multi-byte code page.
Source:		WinHttp.WinHttpRequest
Description:	No mapping for the Unicode character exists in the target multi-byte code page.

HelpFile:		(null)
HelpContext:	0

Specifically: ResponseText

	Line#
	003: Gui,Add,Edit,w800 h500 -Wrap,URLDownloadToVar(url)
	004: Gui,show
	005: Return
	006: {
	007: hObject := ComObjCreate("WinHttp.WinHttpRequest.5.1")
	008: hObject.Open("GET",url)  
	009: hObject.Send()  
--->	010: Return,hObject.ResponseText
	011: }
	012: Exit
	013: Exit
	013: Exit

Continue running the script?



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

I think because the page http://mangafox.me does not exist.

 

Try this url : http://mangafox.me/Directory


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


Im4everlast
  • Members
  • 4 posts
  • Last active: Feb 15 2014 04:03 PM
  • Joined: 28 Jan 2013

The url http://mangafox.me/Directory does return the source code, but the url should be http://mangafox.me/directory which again returns the error I mentioned above :/



Oldman
  • Members
  • 2475 posts
  • Last active: Feb 18 2015 04:57 PM
  • Joined: 01 Dec 2013

Ok, I don't know what I did before.

 

Your script returns an A_LastError 0x8002009.

 

Based on the Microsoft Website, the problem is due to Blob columns returns by SQL Server or any other DBMS. link

 

I think the problem could be solved by hObject.ResponseStream in place of hObject.ResponseText, but I don't know yet how to read the stream directly from the server.

 

A workaround should be to use UrlDownloadToFile, when the UrlDownloadToVar failed. (see below)

#SingleInstance,Force
;<-- Does not work | Works --> http//google.com, http://www.autohotkey.com, ...
url=http://mangafox.me
urlPage := UrlDownloadToVar(url)
if urlPage is integer
{
	UrlDownloadToFile, %url%, Temp1.txt
	FileRead, urlPage, Test.17.txt
}
;Gui,Add,Edit,w800 h500 -Wrap,% URLDownloadToVar(url)
Gui,Add,Edit,w800 h500 -Wrap, % urlPage
Gui,show,
IfExist, Temp1.txt
	FileDelete, Temp1.txt
return

GuiClose:
GuiEscape:
	ExitApp

URLDownloadToVar(url){
	ComObjError(0)
	hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
	hObject.Open("GET",url)
	hObject.Send()
	res := hObject.ResponseText
	if A_LastError
		return A_LastError
	return res
}


Si ton labeur est dur et que tes résultats sont minces, souviens toi du grand chêne qui avant n'était qu'un gland....comme toi ! (anonyme) ;)

L'art de lire, c'est l'art de penser avec un peu d'aide. (É. Faguet)

Windows 3.1. Collector's Edition.     (www.avaaz.org)


tmplinshi
  • Members
  • 245 posts
  • Last active: Mar 12 2015 02:29 PM
  • Joined: 06 Apr 2012

I got this error too. This should work: 

url := "https://secure.photobucket.com/login"
MsgBox, % URLDownloadToVar(url, "utf-8")

URLDownloadToVar(url, Encoding = ""){
	hObject:=ComObjCreate("WinHttp.WinHttpRequest.5.1")
	hObject.Open("GET",url)
	hObject.Send()

	If Encoding {
		oADO          := ComObjCreate("adodb.stream")
		oADO.Type     := 1
		oADO.Mode     := 3
		oADO.Open()
		oADO.Write( hObject.ResponseBody )
		oADO.Position := 0
		oADO.Type     := 2
		oADO.Charset  := Encoding
		return oADO.ReadText(), oADO.Close()
	}
	return hObject.ResponseText
}