贴一个类似的代码以供参考:
- (defun loc:download (url dir / bytes fic file fso http tbl)
- (setq http (vlax-create-object "Msxml2.XMLHTTP")
- fso (vlax-create-object "Scripting.FileSystemObject")
- )
- (vlax-invoke-method http 'open "get" url :vlax-false)
- (vlax-invoke http 'send)
- (while (not (eq (vlax-get http 'readyState) 4))
- (repeat 100)
- )
- (setq file (strcat dir
- (vl-filename-base url)
- (vl-filename-extension url)
- )
- tbl (vlax-safearray->list
- (vlax-variant-value (vlax-get-property http 'responsebody))
- )
- fic (vlax-invoke fso 'CreateTextFile file)
- )
- (foreach bytes tbl
- (vlax-invoke fic 'write (chr bytes));;bytes 有进可能是unicode字符集,对其处理需要注意。
- )
- (vlax-invoke fic 'close)
- (vlax-release-object http)
- (vlax-release-object fso)
- (princ)
- )
|