English 中文(简体)
利用Jsoup实现在线字典结果
原标题:Parsing online dictionary results using Jsoup

我试图利用Jsoup进行网上定购结果,对此我有基本的理解。 http://paste2.org/p/1761539“rel=“nofollow” 页: 1 我试图打碎“基球”和“代谢”,但我没有这样做的干净方法。

最佳回答

很难说,因为这两个词在源代码上都没有独特的识别特征。

But I would do it like that:

Document doc = Jsoup.connect("http://myurl.com").get();
String original = doc.select("td[width=140]").get(1).toString() //get td element which has width of 140 and get the second one
String translated = doc.select("td[align=left]").get(1).toString()//get td element which has align left and get the second one

<>说明: 在通过拆解获取数据时,网站设计/源代码的微小改动可能会削弱你的应用。

问题回答

这里的解决办法是estivate。 (是Java DOM Parser, 附有与联合材料相符的说明)

Document doc = Jsoup.connect("http://myurl.com").get();

EstivateMapper mapper = new EstivateMapper();

Result result = mapper.map(doc, Result.class);

内容提要

public class Result {

    @Text(select = "td[width=140]", index=1)
    public String original;

    @Text(select = "td[align=left]", index=1)
    public String translated;

}




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签