2012-03-23 79 views
0

從頁面檢索指定文本時出現問題。我使用的示例是Patent Assignee Summary使用jericho html解析器解析頁面中的指定文本

如果您訪問該站點,您會看到有一個「Total:82」(這是標準SASA的命中數)。我需要得到這個號碼。我使用jericho html解析器,但我找不到任何功能。

有人可以幫我這個嗎?我真的需要在頁面上獲得這個號碼。

在此先感謝 -Sasa

+0

是否可以從傑里科切換到另一個LIB? – ollo 2013-02-04 16:25:49

回答

0

如果你可以切換到Jsoup

/* Connect to URL and parse it into a 'Document' */ 
Document doc = Jsoup.connect("http://assignments.uspto.gov/assignments/q?db=pat&qt=asne&reel=&frame=&pat=&pub=&asnr=&asnri=&asne=sasa&asnei=&asns=").get(); 

/* Select the required tag and print the value */ 
System.out.println(doc.select("p.t2").first().text()); 

完成!

輸出:

總數:83 (值對網站改變)

選擇器解釋:

doc.select("p.t2") // Select each 'p'-tag with 't2' attribute from document 
    .first() // Get the first one (there are two on the website, but the first one is the required one) 
    .text() // Get the text of this element 

文檔: