unofficial mirror of help-gnu-emacs@gnu.org
 help / color / mirror / Atom feed
From: Stefan Huchler <stefan.huchler@mail.de>
To: help-gnu-emacs@gnu.org
Subject: elisps dom library doesn't work as I expect
Date: Tue, 09 May 2023 05:54:03 +0200	[thread overview]
Message-ID: <87ttwmgnxg.fsf@mail.de> (raw)

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?




             reply	other threads:[~2023-05-09  3:54 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-09  3:54 Stefan Huchler [this message]
2023-05-09  5:32 ` elisps dom library doesn't work as I expect Tim Landscheidt
2023-05-10  3:56   ` Stefan Huchler
2023-05-10 20:18     ` Tim Landscheidt
2023-05-20 19:40       ` Stefan Huchler

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87ttwmgnxg.fsf@mail.de \
    --to=stefan.huchler@mail.de \
    --cc=help-gnu-emacs@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).