0
谁能告诉我这里发生了什么?Racket中的某些xexpressions不通过xexpr?
#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-路径*上失败,与
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,但看起来好的。在其他页面上,代码按我的预期工作。这绝对是关于stackoverflow页面的一些东西。但我无法弄清楚什么。我应该怎么做,如果我得到这样一个几乎OK的xexpr,我可以清理它,让se-path *工作?