微醫網爬蟲(一) java實現

2021-08-19 03:29:33 字數 1750 閱讀 6681

爬取微醫網醫生的基本資料,獲取每個醫生的url之後,可以使用以下方法解析:

想要採集醫生歷史問診詳細資訊的同學可以移步我們另一篇部落格:傳送門

public doctor getdoctorinfor(string url) 

if (sp != null)

}//提取是否為專家

element isa = ele1.selectfirst("a[class=expert-group]");

if (isa != null) else

//提取醫院和科室

element hosdiv = ele1.selectfirst("div[class=hospital]");

if (hosdiv != null)

if (a2 != null)

}//提取擅長領域

element gooddiv = ele1.selectfirst("div[class=goodat]");

if (gooddiv != null)

}//提取簡介

element aboutdiv = ele1.selectfirst("div[class=about]");

if (aboutdiv != null) else }}

}//提取評分,問診量,預約量

element ele2 = doc.selectfirst("div[class=status]");

if (ele2 != null) }}

//提取關注量

element markdiv = doc.selectfirst("div[class=summary]");

if (markdiv != null)

}//提取**

element price = doc.selectfirst("div[class=consult-type]");

if (price != null)

if (pr.size() == 2)

}element commentdiv = doc.selectfirst("section[class=grid-section grid-section-outside expert-comment]");

if (commentdiv != null) }}

//提取問診和回答的數量

element ele3 = doc.selectfirst("section[class=grid-section grid-section-outside expert-history-ask j_experthistoryask]");

if (ele3 != null)

}//提取狀態資訊

element status=doc.selectfirst("div[id=service]");

if(status!=null)

if(attr.contains("tuwen"))

if(attr.contains("shipin"))

if(attr.contains("servicepkg"))}}

}} catch (ioexception e)

system.out.println("---->完成");

return doctor;

}

需要原始碼的同學可以聯絡博主qq(1477517404)。爬取結果:

JAVA 實現網路爬蟲

class bde image src width 560 height 314 pic type 0 public class task implements runnable override public void run image.write buf,0,len 儲存到本地 image.c...

JAVA實現簡單網路爬蟲

這是我第一次寫部落格,所以寫的不算好,看到的人請見諒。gethtml 類,首先是url url1 new url url 模擬在網頁輸入 接著 urlconnection uc url1.openconnection 模擬敲回車鍵開啟該 頁面,後面的看注釋應該能看懂了。bf.readline 是依次...

JAVA使用HttpClient實現爬蟲技術

1.pom檔案中加入httpclient依賴包 2.建立乙個呼叫httpclient的工具類 建立closeablehttpclient 建立requestconfig private void createrequestconfig get請求不帶引數 param url return throw...