Author Topic: How to get Web Page Text line into LISP Variable ?  (Read 4644 times)

0 Members and 1 Guest are viewing this topic.

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
How to get Web Page Text line into LISP Variable ?
« on: March 01, 2014, 02:22:01 PM »
I am sure this can & has been done, however I find little when I search.  I would like to get the only string of test from a web query into a LISP variable with no user input.

Is this possible in LISP ?

Example of code to call web result;

 http://geocoder.us/service/csv/geocode?address=181+gould+rd+weare+nh

Text returned from the above HTTP example = 43.037423,-71.692220,181 Gould Rd,Weare,NH,03281

Other than this text line the page is completely blank.

This is the lat-long coordinates derived from a physical street address.

Any assistance would be helpful.

Thanks,

Bruce



Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to get Web Page Text line into LISP Variable ?
« Reply #1 on: March 01, 2014, 02:32:18 PM »
Try the following function:

Code: [Select]
;; Get URL Text  -  Lee Mac
;; Retrieves all text data for the given URL

(defun LM:geturltext ( url / obj rtn )
    (if (setq obj (vlax-create-object "winhttp.winhttprequest.5.1"))
        (progn
            (setq rtn
                (vl-catch-all-apply
                   '(lambda nil
                        (vlax-invoke-method obj 'open "GET" url :vlax-false)
                        (vlax-invoke-method obj 'send)
                        (vlax-get-property  obj 'responsebody)
                    )
                )
            )
            (vlax-release-object obj)
            (if (vl-catch-all-error-p rtn)
                (prompt (vl-catch-all-error-message rtn))
                (vl-list->string
                    (mapcar '(lambda ( x ) (lsh (lsh x 24) -24))
                        (vlax-safearray->list (vlax-variant-value rtn))
                    )
                )
            )
        )
    )
)

Code: [Select]
_$ (LM:geturltext "http://geocoder.us/service/csv/geocode?address=181+gould+rd+weare+nh")
"43.037423,-71.692220,181 Gould Rd,Weare,NH,03281\n"

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: How to get Web Page Text line into LISP Variable ?
« Reply #2 on: March 01, 2014, 02:39:25 PM »
Lee,

Works great thanks,

Bruce

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to get Web Page Text line into LISP Variable ?
« Reply #3 on: March 01, 2014, 02:41:11 PM »
Excellent  :-)

If you prefer,
Code: [Select]
(lsh (lsh x 24) -24)
Could be equivalently replaced with:
Code: [Select]
(logand x 255)

hozc

  • Guest
Re: How to get Web Page Text line into LISP Variable ?
« Reply #4 on: May 06, 2014, 04:11:30 AM »
Lee,

How about getting a txt file from a web page and save it to a specified folder in your computer. This can be used for automatic updating of lisp routines remotely.

Thanks and regards.

Haluk

snownut2

  • Swamp Rat
  • Posts: 971
  • Bricscad 22 Ultimate
Re: How to get Web Page Text line into LISP Variable ?
« Reply #5 on: May 06, 2014, 06:18:55 AM »
Lee,

How about getting a txt file from a web page and save it to a specified folder in your computer. This can be used for automatic updating of lisp routines remotely.

Thanks and regards.

Haluk

Do a bit of searching, that has been posted here somewhere.

Bruce

hozc

  • Guest
Re: How to get Web Page Text line into LISP Variable ?
« Reply #6 on: May 06, 2014, 07:35:20 AM »
vla-GetRemoteFile  is the answer. Anyway thank you all.

Haluk

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to get Web Page Text line into LISP Variable ?
« Reply #7 on: May 06, 2014, 05:44:59 PM »

hozc

  • Guest
Re: How to get Web Page Text line into LISP Variable ?
« Reply #8 on: May 07, 2014, 02:13:45 AM »
Lee,

This is much better.

Thank you

Haluk

Lee Mac

  • Seagull
  • Posts: 12914
  • London, England
Re: How to get Web Page Text line into LISP Variable ?
« Reply #9 on: May 07, 2014, 06:20:58 PM »
You're welcome - all credit to VovKa  8-)