[英]Clojure: using library functions from REPL
I've just started with Clojure and have never used Java 我刚开始使用Clojure并且从未使用过Java
I understood how to create and run a leiningen project from terminal, but I can't understand how to load libraries in REPL before running commands. 我理解如何从终端创建和运行leiningen项目,但我无法理解如何在运行命令之前在REPL中加载库。
I'm trying to build a simple web scrapler with clj-webdriver; 我正在尝试使用clj-webdriver构建一个简单的Web剪贴器; my original file looks like this
我的原始文件看起来像这样
(ns prova.core (:gen-class))
(use 'clj-webdriver.taxi)
(set-driver! {:browser :firefox})
(defn -main
[& args]
(to "https://github.com/login")
(input-text "#login_field" "email")
(input-text "#password" "psw")
(click "input[name='commit']")
)
The closest I (think) have got to achieve it was going into the webdriver src folder and try this command 最接近我(想)必须实现它的是进入webdriver src文件夹并尝试此命令
penta@laptop:~/clj-webdriver-master/src/clj_webdriver$ clojure
Clojure 1.4.0
user=> (use 'taxi)
but it returned 但它回来了
FileNotFoundException Could not locate taxi__init.class or taxi.clj on classpath: clojure.lang.RT.load (RT.java:432)
even thou in the same folder the file taxy.clj was indeed present. 即使你在同一个文件夹中,文件taxy.clj确实存在。
So, what is the procedure to run a REPL that can make use of a library functions? 那么,运行可以使用库函数的REPL的过程是什么?
Many thanks 非常感谢
Take a look at the leiningen build tool, install it according to the website's instructions and make a new project. 看看leiningen构建工具,根据网站的说明安装它并制作一个新项目。
lein new myproject
cd myproject
Then edit project.clj
in which you add clj-webdriver as a dependency: 然后编辑
project.clj
在其中添加clj-webdriver作为依赖项:
(defproject myproject "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.5.1"]
[clj-webdriver "0.6.0"]])
Then type lein repl
and a REPL will spin up with clj-webdriver on the classpath. 然后键入
lein repl
,REPL将在类路径上使用clj-webdriver旋转。 You should now be able to continue as you did in your example. 您现在应该能够像在示例中那样继续。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.