[英]Can´t execute jSoup Parser
I have been looking for information in order to use jSoup so that I can extract some elements from another website, but I can't make it run.我一直在寻找信息以使用jSoup,以便我可以从另一个网站提取一些元素,但是我无法运行它。
I have installed Java and Maven, I created a Java file and then a pom.xml dependency, but when I execute it on Terminal (I'm using Mac), it gives me errors.我已经安装了 Java 和 Maven,我创建了一个 Java 文件,然后创建了一个 pom.xml 依赖项,但是当我在终端(我使用的是 Mac)上执行它时,它给了我错误。
I'm totally lost.我完全迷路了。 I can't even run a simple code so that I can start understanding.
我什至不能运行一个简单的代码来开始理解。 I have make several google search but all the tutorials start over a basic knowledge.
我已经进行了几次谷歌搜索,但所有的教程都是从基本知识开始的。
I would appreciate if you could tell me where could I start from 0 knowledge, because I´m getting desperate.如果您能告诉我从 0 知识开始我可以从哪里开始,我将不胜感激,因为我快绝望了。
The pom.xml file describes your project so that Maven knows how to compile it. pom.xml 文件描述了您的项目,以便 Maven 知道如何编译它。 At a minimum you need to define your project's group ID, artifact ID, and version--the Maven "coordinates."
您至少需要定义项目的组 ID、工件 ID 和版本——Maven“坐标”。 If your project requires libraries, like jsoup, then you can include a <dependencies> section with a <dependency> for each library.
如果您的项目需要库,例如 jsoup,那么您可以为每个库包含一个 <dependencies> 部分和一个 <dependency>。 I think you've gotten this far.
我想你已经到了这一步。
Maven expects the project to have a certain structure. Maven 期望项目具有一定的结构。
Sorry if some of this is review for you.对不起,如果其中一些是对您的评论。
You should run Maven (mvn) from the top directory containing pom.xml:您应该从包含 pom.xml 的顶级目录运行 Maven (mvn):
$ mvn install
That should download jsoup and compile anything in src/main/java.那应该下载 jsoup 并编译 src/main/java 中的任何内容。
Then you can run "mvn exec:java ..." from the same directory.然后您可以从同一目录运行“mvn exec:java ...”。
You didn't need maven in order to run JSoup, you can:你不需要 maven 来运行 JSoup,你可以:
jsoup jar
from jsoup.org ,jsoup jar
,jsoup
in your classjsoup
and you're good to go.你可以走了。
POM.xml
, so it looks :POM.xml
将 jsoup 依赖项添加到 pom,因此它看起来像: pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.yourorgaaniztion</groupId>
<artifactId>jsoup-with-maven</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>org.jsoup</groupId>
<artifactId>jsoup</artifactId>
<version>1.10.1</version>
</dependency>
</dependencies>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
</project>
the project structure (pom.xml location) should looks like:项目结构(pom.xml 位置)应如下所示:
I would appreciate if you could tell me where could I star from 0 knowledge, >because I´m getting desperate.
如果您能告诉我从 0 知识开始我可以在哪里出演,我将不胜感激,>因为我快绝望了。
from this point, I think you could continue with this mkyong tutorial从这一点来说,我想你可以继续这个 mkyong 教程
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.