Jsoup小Demo
public class JsoupUtil { public void parseWangYi() { Document doc = null;
try {
//eg1:解析百度音乐
doc = Jsoup.connect("http://list.mp3.baidu.com/top/singer/A.html").get();
Element singerListDiv = doc.getElementsByAttributeValue("class", "content").first();
Elements links = singerListDiv.getElementsByTag("a"); for (Element link : links) {
String linkHref = link.attr("href");
String linkText = link.text().trim();
System.out.println(linkHref + "==============" + linkText);
} //eg2:解析万年历 可以根据输入的日期,生成相应的阴历万年历解析
Document docs = Jsoup.connect("http://www.nongli.com/item4/index.asp?dt=2015-02-26").get();
Element infoTable = docs.getElementsByAttributeValue("class", "table002").first();
Elements tableLineInfos = infoTable.select("tr");
for (Element lineInfo : tableLineInfos) {
String lineInfoContent = lineInfo.select("td").last().text().trim();
System.out.println("jsoup is :" + lineInfoContent);
} } catch (IOException e) {
e.printStackTrace();
} } }
拿到的结果: http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=A+BOYS%C0%D6%B6%D3==============A BOYS乐队
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=A+ONE==============A ONE
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=A-SHOW==============A-SHOW
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=A.J.Alex==============A.J.Alex
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=A4==============A4
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=AFI==============AFI
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=AJerks==============AJerks
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=AM+%C0%D6%CD%C5==============AM 乐团
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=AOK==============AOK
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=ASOS==============ASOS
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=AY%B0%AE%C0%D6%B9%AB%C9%E7==============AY爱乐公社
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Aaron+Carter==============Aaron Carter
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Air+Supply==============Air Supply
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Airbag==============Airbag
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Ak-47==============Ak-47
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Akon==============Akon
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Alicia+Keys==============Alicia Keys
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Alizee==============Alizee
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Alt+Senior==============Alt Senior
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Andrea+Bocelli==============Andrea Bocelli
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Angela==============Angela
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Art+Pepper==============Art Pepper
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=At17==============At17
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=August+band==============August band
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=Avril+Lavigne==============Avril Lavigne
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=ado==============ado
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=anida==============anida
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2Bert==============阿Bert
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B1%A6==============阿宝
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B1%AC==============阿爆
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B1%BE==============阿本
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B2%BC%C1%D0%D7%C8%C4%F9==============阿布列兹涅
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B2%C5==============阿才
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B5%C2==============阿德
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B5%C6==============阿灯
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B5%DC==============阿弟
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B5%DC%D7%D0==============阿弟仔
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B6%C5==============阿杜
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B6%E4==============阿朵
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B8%A3==============阿福
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B8%F1==============阿格
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B9%F3==============阿贵
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%B9%FB==============阿果
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%BA%C6==============阿浩
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%BB%AA==============阿华
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%BC%AA%D7%D0==============阿吉仔
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%BC%D1==============阿佳
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%BC%D1%D7%E9%BA%CF==============阿佳组合
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C0%B3%C0%D6%B6%D3==============阿莱乐队
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C0%BC.%B4%EF%CD%DF%D7%BF%C2%EA==============阿兰.达瓦卓玛
#==============
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C0%CA==============阿朗
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C0%EF%C0%C9==============阿里郎
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C0%F6%C2%EA==============阿丽玛
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C1%C1==============阿亮
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C1%FA%D5%FD%EE%B8==============阿龙正罡
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C2%B3%B0%A2%D7%BF==============阿鲁阿卓
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C2%D6==============阿轮
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C3%A8%B0%A2%B9%B7==============阿猫阿狗
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C3%C3%C3%C3==============阿妹妹
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C4%BE==============阿木
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C4%BE%B9%C5%E3%B6==============阿木古愣
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C4%C2%C2%A1==============阿穆隆
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C5%A3==============阿牛
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C7%BF==============阿强
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C7%C4==============阿悄
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C7%DF==============阿沁
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C7%E5==============阿清
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C8%D5%B2%BC%BD%DC==============阿日布杰
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C8%E3%C4%C8==============阿茹娜
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%C9%A3==============阿桑
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%CC%A9==============阿泰
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%CE%A8==============阿唯
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D0%C5==============阿信
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D1%87==============阿?
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D1%C5==============阿雅
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D2%F7%C7%D9==============阿吟琴
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D3%C2%D4%F3%C8%C3==============阿勇泽让
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D3%D7%B6%E4==============阿幼朵
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D4%C6%B8%C2==============阿云嘎
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D5%FD==============阿正
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%D8%F4==============阿佤
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A2%F4%C2==============阿袈
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A5%DF%BA%C0%D6%B6%D3==============哎吆乐队
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%A7%CD%AC%CB%BF==============哀同丝
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%B3%C9==============艾成
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%B6%FB%BF%CF==============艾尔肯
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%B8%E8==============艾歌
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%BE%B4==============艾敬
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%BE%FB%CE%B0==============艾钧伟
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%BF%C9==============艾可
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%C0%F2%C9%AF==============艾莉莎
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%C1%D5==============艾琳
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%C3%CE%C3%C8==============艾梦萌
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%C7%E7%C7%E7==============艾晴晴
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%CB%B9%BF%A8%B6%FB==============艾斯卡尔
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%D0%C4==============艾心
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%D3%EA==============艾雨
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AC%E9%F3%C2%FC==============艾轶曼
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AE%B4%F7==============爱戴
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AE%BB%DB%C4%C8==============爱慧娜
#==============
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%AE%C0%D6%CD%C5==============爱乐团
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%B0%D9%BB%DB==============安百慧
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%B2%AE%D5%FE==============安伯政
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%B5%C2%D7%F0==============安德尊
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%B5%CF==============安迪
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%B9%C8==============安谷
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%BF%B5==============安康
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%C6%DF%EC%C5==============安七炫
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%C9%D9%D3%EE==============安少宇
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%CA%D2%C4%CE%C3%C0%BB%DD==============安室奈美惠
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%CC%CE==============安涛
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%D0%F1==============安旭
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%D2%D4%D0%F9==============安以轩
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%D3%D6%E7%F7==============安又琪
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%D3%EB%C6%EF%B1%F8==============安与骑兵
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%D4%DA%D0%F1==============安在旭
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%D6%BE%BD%DC==============安志杰
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%E7%F7%B6%F9==============安琪儿
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%E7%FA==============安琥
http://mp3.baidu.com/m?rf=top-singer&tn=baidump3&ct=134217728&lm=-1&word=%B0%B2%F6%A9==============安雯
#==============
jsoup is :正月(小)初八 星期四 双鱼座
jsoup is :乙未年 生肖属羊 戊寅月 癸酉日
jsoup is :纳采 订盟 祭祀 祈福 安香 出火 修造 出行 开市 移徙 入宅 动土 安葬 破土
jsoup is :安床 作灶 造船 会亲友
jsoup is :除神 阴德 鸣犬
jsoup is :五离 天吏 五虚 元武
jsoup is :房床门外西南
jsoup is :剑锋金 危执位
jsoup is :冲兔(丁卯)煞东
jsoup is :癸不词讼理弱敌强 酉不宴客醉坐颠狂