all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* http-get and GDS (Google Desktop Search)
@ 2006-02-08  7:13 Mathias Dahl
       [not found] ` <dsc7e6$t7d$1@news.sap-ag.de>
  0 siblings, 1 reply; 6+ messages in thread
From: Mathias Dahl @ 2006-02-08  7:13 UTC (permalink / raw)



I am trying to see if I can make a simple Emacs-interface to leverage
the search functionality of Google Desktop Search. This is what I have
right now:

(require 'http-get)

(defvar gds-url nil
  "GDS URL")

(setq gds-url "http://127.0.0.1:4664/search&s=long_secure_token_or_whatever?q=")

(defun gds-test ()
  (http-get 
   (concat gds-url "emacs")))

When I evaluate (gds-test) I get nothing in return.

If I paste the same URL in the shell and use wget, it can fetch the
data, so the URL syntaxt is correct.

NOTE: The `long_secure_token_or_whatever' above is something else on
my system, but I get the feeling that I should not post that publicly.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: http-get and GDS (Google Desktop Search)
       [not found] ` <dsc7e6$t7d$1@news.sap-ag.de>
@ 2006-02-08 10:18   ` Mathias Dahl
  2006-02-08 11:20     ` Xavier Maillard
       [not found]     ` <mailman.229.1139401011.3144.help-gnu-emacs@gnu.org>
  0 siblings, 2 replies; 6+ messages in thread
From: Mathias Dahl @ 2006-02-08 10:18 UTC (permalink / raw)


Klaus Straubinger <KSNetz@UseNet.ArcorNews.DE> writes:

> Why don't you use the built-in (at least in your Emacs version, I assume
> from "User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt)")
> URL package to retrieve data from a URL?

Yeah, why don't I? :)

I did not know about it. I just looked it up and it does not even have
a docstring and no info how it works. When looking at the code I
stumbled upon `url-retrieve-synchronously', which has some
documentation. I'll look into using one of these.

Thanks for the hint!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: http-get and GDS (Google Desktop Search)
  2006-02-08 10:18   ` Mathias Dahl
@ 2006-02-08 11:20     ` Xavier Maillard
       [not found]     ` <mailman.229.1139401011.3144.help-gnu-emacs@gnu.org>
  1 sibling, 0 replies; 6+ messages in thread
From: Xavier Maillard @ 2006-02-08 11:20 UTC (permalink / raw)
  Cc: help-gnu-emacs

   From: Mathias Dahl <brakjoller@gmail.com>

   Klaus Straubinger <KSNetz@UseNet.ArcorNews.DE> writes:

   > Why don't you use the built-in (at least in your Emacs version, I assume
   > from "User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (windows-nt)")
   > URL package to retrieve data from a URL?

   Yeah, why don't I? :)

   I did not know about it. I just looked it up and it does not even have
   a docstring and no info how it works. When looking at the code I
   stumbled upon `url-retrieve-synchronously', which has some
   documentation. I'll look into using one of these.

Feedback welcome if url.el works for you. I also tried to do a webapp using
url but I gave up and turned back on http package which is much more
straightforward (documentation, etc...).

Xavier

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: http-get and GDS (Google Desktop Search)
       [not found]       ` <dscrkm$gn3$1@news.sap-ag.de>
@ 2006-02-08 13:52         ` Mathias Dahl
       [not found]           ` <dscu4r$k1q$1@news.sap-ag.de>
  0 siblings, 1 reply; 6+ messages in thread
From: Mathias Dahl @ 2006-02-08 13:52 UTC (permalink / raw)


Klaus Straubinger <KSNetz@UseNet.ArcorNews.DE> writes:

> It works for me. I use it in Gnus to retrieve some RSS groups
> and of course together with Emacs/W3.

It works for me too:

;; Emacs GDS-prototype

(require 'xml)

(defvar gds-base-url nil
  "")

(setq gds-base-url "http://127.0.0.1:4664/search&s=SECURITY-TOKEN")

(defun gds-get-xml-response (search)
  "Do a Google Desktop Search for SEARCH, return result as xml"
  (let (data xml
        gds-buffer
        (url-buffer
         (url-retrieve-synchronously 
          (format "%s?q=%s&format=xml" gds-base-url search))))
    (save-excursion
      (set-buffer url-buffer)
      (setq data (buffer-substring (point-min) (point-max)))
      ;; Create our own buffer if we need to look at the data for
      ;; debugging purposes.
      (setq gds-buffer (get-buffer-create "*gds"))
      (set-buffer gds-buffer)
      (erase-buffer)
      (insert data)
      (goto-char (point-min))
      (if (not (search-forward-regexp "^<\\?xml" nil t))
          (message "No XML data from GDS search")
        (setq xml (xml-parse-region (match-beginning 0) (point-max)))))))

;; Code ends here

Now it's just a matter of doing something useful with this, add a
couple of options etc...

/Mathias

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: http-get and GDS (Google Desktop Search)
       [not found]           ` <dscu4r$k1q$1@news.sap-ag.de>
@ 2006-02-08 15:32             ` Mathias Dahl
  2006-02-08 19:00               ` Mathias Dahl
  0 siblings, 1 reply; 6+ messages in thread
From: Mathias Dahl @ 2006-02-08 15:32 UTC (permalink / raw)


Klaus Straubinger <KSNetz@UseNet.ArcorNews.DE> writes:

> Now if you have a look at what url-insert-file-contents does, you will
> see that you can save several lines of code by using it.
>
> (defun gds-get-xml-response (search)
>   "Do a Google Desktop Search for SEARCH, return result as xml"
>   (with-temp-buffer
>     (url-insert-file-contents
>      (format "%s?q=%s&format=xml" gds-base-url search))
>     (goto-char (point-min))
>     (if (not (search-forward-regexp "^<\\?xml" nil t))
>         (message "No XML data from GDS search")
>       (xml-parse-region (match-beginning 0) (point-max)))))

Ooops! :)

Thanks!

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: http-get and GDS (Google Desktop Search)
  2006-02-08 15:32             ` Mathias Dahl
@ 2006-02-08 19:00               ` Mathias Dahl
  0 siblings, 0 replies; 6+ messages in thread
From: Mathias Dahl @ 2006-02-08 19:00 UTC (permalink / raw)


Mathias Dahl <brakjoller@gmail.com> writes:

Just posted some code with a working implementation of this to
gnu.emacs.sources.

Enjoy!

/Mathias

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-02-08 19:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-08  7:13 http-get and GDS (Google Desktop Search) Mathias Dahl
     [not found] ` <dsc7e6$t7d$1@news.sap-ag.de>
2006-02-08 10:18   ` Mathias Dahl
2006-02-08 11:20     ` Xavier Maillard
     [not found]     ` <mailman.229.1139401011.3144.help-gnu-emacs@gnu.org>
     [not found]       ` <dscrkm$gn3$1@news.sap-ag.de>
2006-02-08 13:52         ` Mathias Dahl
     [not found]           ` <dscu4r$k1q$1@news.sap-ag.de>
2006-02-08 15:32             ` Mathias Dahl
2006-02-08 19:00               ` Mathias Dahl

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/emacs.git
	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.