Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Php Document Download problem
#1
download_url : http://torrentlee.com/bbs/download.php? ... d=512&no=0

downloaded from the Internet Explorer : OK
but Download error in QM

header send is same all
Why Would not download?

Function test
Code:
Copy      Help
str url1 = "http://torrentlee.com"
str    Download_Url = "/bbs/download.php?bo_table=etc&wr_id=512&no=0"
str    headers =
;Accept: text/html, application/xhtml+xml, */*
;Referer: http://torrentlee.com/bbs/board.php?bo_table=etc&wr_id=512
;Accept-Language: ko-KR
;User-Agent: Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
;Accept-Encoding: deflate
;Host: torrentlee.com
;Connection: Keep-Alive
;Cookie: __cfduid=df42ae21a01cb5546fec6c605ea1f15821432616112; PHPSESSID=difki4nt53jgl4tu660m27clj6; f33d2ed86bd82d4c22123c9da444d8ab=MTQzMjYxNTk1Ng%3D%3D; 96b28b766b7e0699aa91c9ff3d890663=aHR0cDovL3d3dy5nb29nbGUuY28ua3IvdXJsP3NhPXQmcmN0PWomcT0mZXNyYz1zJmZybT0xJnNvdXJjZT13ZWImY2Q9OSZ2ZWQ9MENGRVFGakFJJnVybD1odHRwJTNBJTJGJTJGdG9ycmVudGxlZS5jb20lMkZiYnMlMkZib2FyZC5waHAlM0Zib190YWJsZSUzRGtvcl9kb2N1JTI2d3JfaWQlM0QxNzYlMjZwYWdlJTNENTklMjZwYWdlJTNENTkmZWk9cFB4alZZU0RHWUtDOGdYQzhZRElCQSZ1c2c9QUZRakNORk1tUXlIYlNBQmxrR1E5d3lCRmxIdEZqT1NidyZidm09YnYuOTM5OTA2MjIsZC5kR2M%3D; wcs_bt=e053f97fe46850:1432623268

str Download_Path ResponeHeader
Http h.Connect(url1)
,h.Get3(Download_Url Download_Path 1 INTERNET_FLAG_KEEP_CONNECTION ResponeHeader headers)
,out Download_Path

str FileNamePattern =
;;filename="(.*?)"

ARRAY(str) TorrentName; int i
if(!findrx(ResponeHeader FileNamePattern 0 4 TorrentName)) out "NotFound";ret
for(i 0 TorrentName.len)
,str GetTorrent=TorrentName[1 i]
,,GetTorrent.findreplace("+" "_")
,str path.format("$desktop$\%s" GetTorrent)
,out Download_Path.setfile(path)
#2
Try this function.

Function IntGetFileWH
Code:
Copy      Help
;/
function# $url str&s [str&responseHeaders] [$requestHeaders]

;Downloads web page or other file from the Internet.
;Returns HTTP status code (200 is OK).
;Error if failed.

;url - file to download. Example: "http://www.x.com/index.htm"
;s - variable that receives file data.
;responseHeaders - variable that receives response headers.
;requestHeaders - headers to send, like "name1: value1[]name2: value2[]...".

;REMARKS
;There are 2 ways specify proxy settings:
;;;1. Call <help>IntSettings</help> with useproxy = 1 and proxy_name etc. The this function will call <link "https://msdn.microsoft.com/en-us/library/windows/desktop/aa384059%28v=vs.85%29.aspx">WinHttpRequest.SetProxy</link> with these settings.
;;;2. Run WinHTTP proxy configuration utility <link "https://msdn.microsoft.com/en-us/library/windows/desktop/aa384069%28v=vs.85%29.aspx">Netsh.exe or ProxyCfg.exe</link>. These proxy settings are used by this function and WinHTTP functions, and are not those used by Internet Explorer and WinInet functions that are used by IntGetFile and other QM functions.
;To not use a proxy, call IntSettings with useproxy = 2, or don't configure proxy settings with the configuration utilities.

;EXAMPLE
;str s
;int status=IntGetFileWH("http://www.quickmacros.com/index.html" s)
;if(status!=200) end F"failed, status={status}"
;out s


opt noerrorshere 1
typelib WinHttp {662901FC-6951-4854-9EB2-D9A2570F2B2E} 5.1

WinHttp.WinHttpRequest r._create

;apply IntSettings
sel __intsett.useproxy
,case 1 r.SetProxy(2 __intsett.proxy_name __intsett.proxy_bypass)
,case 2 r.SetProxy(1)

r.Open("GET" url)
foreach _s requestHeaders
,str hName hValue
,if(tok(_s &hName 2 ":" 0x2002)<2) end "requestHeaders must be: ''name1: value1[91]]name2: value2[91]]...''"
,r.SetRequestHeader(hName hValue)
,int isUA; if(matchw(hName "User-Agent" 1)) isUA=1
if(!isUA) r.SetRequestHeader("User-Agent" iif(__intsett.user_agent.len __intsett.user_agent "Quick Macros"))
r.Send
;r.WaitForResponse
if(&responseHeaders) responseHeaders=r.GetAllResponseHeaders
ARRAY(byte) a=r.ResponseBody
s.fromn(&a[0] a.len)
ret r.Status


Forum Jump:


Users browsing this thread: 1 Guest(s)