本帖最后由 highflybird 于 2022-9-10 10:09 编辑
很好的方法。我这里也提供一个网站。各位可以根据这个思路替换其它网站,这个方法不用生成临时文件。
- (defun HFB:InternetTime (/ xml url str pos val)
- (setq xml (vlax-create-object "Msxml2.XMLHTTP"))
- (setq url "http://api.k780.com:88/?app=life.time&appkey=10003&sign=b59bc3ef6191eb9f747dd4e83c99f2a4&format=json")
- (vlax-invoke xml 'open "GET" url nil)
- ;(vlax-invoke xml 'SetRequestHeader "If-Modified-Since" "0")
- (vlax-invoke xml 'send)
- (if (= "OK" (vlax-get xml 'statusText))
- (setq str (vlax-get xml 'responsetext)
- xml (vlax-release-object xml)
- pos (+ 14 (vl-string-search "datetime_1" str))
- val (substr str pos 19)
- )
- )
- )
或者这样:
- (defun HFB:InternetTime ( / xml url)
- (setq xml (vlax-create-object "Msxml2.XMLHTTP"))
- (setq url "https://www.baidu.com")
- (vlax-invoke xml 'open "GET" url nil)
- (vlax-invoke xml 'send)
- (command "delay" 200)
- (vlax-invoke xml 'GetResponseHeader "Date")
- )
|