This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-06-19
Channels
- # announcements (9)
- # babashka (11)
- # beginners (157)
- # calva (10)
- # cider (18)
- # clara (4)
- # clj-kondo (40)
- # cljsrn (8)
- # clojure (29)
- # clojure-europe (11)
- # clojure-italy (1)
- # clojure-nl (2)
- # clojure-spec (4)
- # clojure-sweden (1)
- # clojure-uk (39)
- # clojurescript (32)
- # conjure (1)
- # core-async (2)
- # cursive (20)
- # datomic (7)
- # duct (9)
- # emacs (1)
- # figwheel-main (1)
- # fulcro (24)
- # helix (1)
- # hoplon (20)
- # hugsql (3)
- # jackdaw (5)
- # jobs-discuss (7)
- # lambdaisland (1)
- # malli (5)
- # music (4)
- # off-topic (54)
- # parinfer (2)
- # pedestal (13)
- # re-frame (12)
- # reagent (22)
- # reitit (9)
- # shadow-cljs (89)
- # spacemacs (2)
- # xtdb (21)
in advanced-optmization browser builds, I always get var process={}
this appears after foreign-libs and before my actual code. the variable is not actually referred to in any of the output of the builds. This is on recent versions of cljs - not sure about older versions.
Anyone know what it's doing there? I mean I guess it has something to do with node, which has always provides process object.
As you might guess it's causing a problem with a non-cljs library that must be using the presence of this to decide what platform it's on
likely the :process-shim
compileroption? I'm not sure what the default is, might be true?
yes, defaults to true for non-node https://clojurescript.org/reference/compiler-options#process-shim
suppose I want to bold some text in a div:
[:div "This is some text and THIS should be bold."]
and I want "THIS" to be bold. Do I have to split the div, or can this be done within the string?I've used enlive
ages ago for something similar - it did give me data structures from html, but I don't think it was hiccup
if there's something that does do html->hiccup reliably I don't know of it
yeah - it ha functions to extract data from html
So long as it is parsable it will suit the need. Doesn't have to be huicup. how did the api work for converting an html string to a parsable data structure?
the html-resource function, if I recall correctly
see the example here https://github.com/cgrand/enlive/wiki#screenscraping-examples
This example there:
(-> " " URL. html-resource
(select [:body :img]) first :attrs :src)
gives nilperhaps the structure of the page has changed - if you just stop at html-resource, what does that look like?
Yeah that returns
({:type :dtd, :data ["HTML" "-//IETF//DTD HTML 2.0//EN" ""]}
{:tag :html,
:attrs nil,
:content
({:tag :head,
:attrs nil,
:content ("\n" {:tag :title, :attrs nil, :content ("302 Found")} "\n")}
{:tag :body,
:attrs nil,
:content
("\n"
{:tag :h1, :attrs nil, :content ("Found")}
"\n"
{:tag :p,
:attrs nil,
:content
("The document has moved "
{:tag :a,
:attrs {:href " "},
:content ("here")}
".")}
"\n"
{:tag :hr, :attrs nil, :content nil}
"\n"
{:tag :address,
:attrs nil,
:content
("Apache/2.4.38 (Debian) Server at Port 80")}
"\n")}
"\n")})
but on another url I tried, this error is thrown:
Execution error (UnknownServiceException) at java.net.URLConnection/getContentHandler (URLConnection.java:1241).
no content-type
URLConnection.java: 1241 java.net.URLConnection/getContentHandler
URLConnection.java: 740 java.net.URLConnection/getContent
URL.java: 1081 java.net.URL/getContent
enlive_html.clj: 115 net.cgrand.enlive-html/eval44675/fn
MultiFn.java: 234 clojure.lang.MultiFn/invoke
enlive_html.clj: 69 net.cgrand.enlive-html/html-resource
enlive_html.clj: 66 net.cgrand.enlive-html/html-resource
REPL: 115 user/eval45429
REPL: 115 user/eval45429
Compiler.java: 7177 clojure.lang.Compiler/eval
Compiler.java: 7132 clojure.lang.Compiler/eval
core.clj: 3214 clojure.core/eval
core.clj: 3210 clojure.core/eval
interruptible_eval.clj: 91 nrepl.middleware.interruptible-eval/evaluate/fn
main.clj: 437 clojure.main/repl/read-eval-print/fn
main.clj: 437 clojure.main/repl/read-eval-print
main.clj: 458 clojure.main/repl/fn
main.clj: 458 clojure.main/repl
main.clj: 368 clojure.main/repl
RestFn.java: 137 clojure.lang.RestFn/applyTo
core.clj: 665 clojure.core/apply
core.clj: 660 clojure.core/apply
regrow.clj: 18 refactor-nrepl.ns.slam.hound.regrow/wrap-clojure-repl/fn
RestFn.java: 1523 clojure.lang.RestFn/invoke
interruptible_eval.clj: 84 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 56 nrepl.middleware.interruptible-eval/evaluate
interruptible_eval.clj: 155 nrepl.middleware.interruptible-eval/interruptible-eval/fn/fn
AFn.java: 22 clojure.lang.AFn/run
session.clj: 190 nrepl.middleware.session/session-exec/main-loop/fn
session.clj: 189 nrepl.middleware.session/session-exec/main-loop
AFn.java: 22 clojure.lang.AFn/run
Thread.java: 748 java.lang.Thread/run
that's odd - must be the kind of thing browsers work around automatically...
i think i remember looking at this once. its not super fun to parse a string as opposed to a resource based thing. either file uri or net uri
In this particular case, there seems to be no api, so the html page must be fetched and parsed to extract the data