all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* elisps dom library doesn't work as I expect
@ 2023-05-09  3:54 Stefan Huchler
  2023-05-09  5:32 ` Tim Landscheidt
  0 siblings, 1 reply; 5+ messages in thread
From: Stefan Huchler @ 2023-05-09  3:54 UTC (permalink / raw)
  To: help-gnu-emacs

I try to webscrape ebay auctions, but I can't scape the name as example:

(defun ebay-tracker--query-test (id)
  "Webscrape ebay auction by ID."
  (setq ebay-tracker-running 't)
  (let* ((auction-url (format "https://www.ebay.com/itm/%s" id)))
    (request auction-url
      :parser (lambda ()
		(goto-char (point-min))
		(re-search-forward "^$")
		;; (next-line)
		(libxml-parse-html-region (point) (point-max)))
      :headers '(("Content-Type" . "application/json"))
      :success (cl-function (lambda (&key data &allow-other-keys)
			      (when data
				(setq ebay-tracker-auction
				      data)
				(message "success")
				(setq ebay-tracker-running nil))))))
  (while ebay-tracker-running
    (sleep-for 0.03))  
  (print (length (dom-elements
		  (dom-by-tag ebay-tracker-auction 'meta)
		  'itemprop "name"))))

;; data that I try to scrape:
;; <meta itemprop="name" content="Sony Bravia XR-55A90J  OLED TV - TOP">
(ebay-tracker--query-test "185887279856")

Also the dom-elements funktion is not described on the gnu website, yet
it's the only way to find elements with this library that don't use
class or id as attributes. shouldn't that code find this node?




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

end of thread, other threads:[~2023-05-20 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-05-09  3:54 elisps dom library doesn't work as I expect Stefan Huchler
2023-05-09  5:32 ` Tim Landscheidt
2023-05-10  3:56   ` Stefan Huchler
2023-05-10 20:18     ` Tim Landscheidt
2023-05-20 19:40       ` Stefan Huchler

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.