[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
elisps dom library doesn't work as I expect
From: |
Stefan Huchler |
Subject: |
elisps dom library doesn't work as I expect |
Date: |
Tue, 09 May 2023 05:54:03 +0200 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) |
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?
- elisps dom library doesn't work as I expect,
Stefan Huchler <=