有人能告诉我这是怎么回事吗?
#lang racket
(require (planet neil/html-parsing:2:0)
net/url xml/path xml)
(define page "http://stackoverflow.com/questions/18902934/compile-and-run-eclipse-project-from-command-prompt")
(define port (get-pure-port (string->url page) ))
(define xexp (html->xexp port))
(displayln xexp)
(xexpr? xexp)
(define title (se-path* '(title) xexp))
(displayln title)它向下拉一个html页面,并将其转换为xexpr。从这个意义上说,html->xexp不会失败。结果看上去像是我所期待的。
但是(xexpr? xexp)返回#f并尝试调用se-path*失败,
se-path*: contract violation
expected: xexpr?
given: '(*TOP* (*DECL* DOCTYPE html) "\n" (html (@ (itemscope) (itemtype "http://schema.org/QAPage")) "\n" (head "\n" "\n" (title "java - Compile and run Eclipse Project from command prompt - Stack Overflow") "\n" " " (link (@ (rel "shortcut icon") (h...
in: the 2nd argument of
(-> se-path? xexpr? any/c)
contract from: <collects>/xml/path.rkt
blaming: anonymous-module
at: <collects>/xml/path.rkt:74.2因此(html->xexp端口)可能会产生无效的xexpr。
我该如何调试这个呢?就像我说的,它是一大块xexpr,但看起来还可以。在其他页面上,代码就像我所期望的那样工作。这肯定是关于堆叠溢出页面的。但我想不出是什么。如果我得到这样一片几乎没问题的xexpr,我可以清理它,这样像se-path*之类的东西就可以工作了,我该怎么办呢?
发布于 2016-03-09 01:35:03
啊..。这似乎解释了
http://www.neilvandyke.org/racket/sxml-intro/
sxml/xexp与xexpr不同
但这似乎是一种常见的混淆,所以我将这个问题留在这里,以防其他人遇到类似的问题。
https://stackoverflow.com/questions/35879617
复制相似问题