当前位置:网站首页>Jsup crawls Baidu Encyclopedia
Jsup crawls Baidu Encyclopedia
2022-07-03 12:07:00 【Dull Yanan】
download Jsoup Of jar rely on , Add to project file
getMessage() Method to enter the content you want to encyclopedia , Function return Encyclopedia ;
public String getMessage(String search) throws Exception
{
String url="https://baike.baidu.com/item/"+search;
URL url1=new URL(url);
Document doc1= Jsoup.parse(url1,1000);
Elements eles=doc1.getElementsByAttributeValue("name","description");
String f1= String.valueOf(eles);
String s[]=f1.split("=");
String str=s[2];
String pattern = "[\\w\\u4e00-\\u9fa5\\u3002\\uff1b\\uff0c\\uff1a\\u201c\\u201d\\uff08\\uff09\\u3001\\uff1f\\u300a\\u300b]";
String ans=" ";
Pattern r = Pattern.compile(pattern);
Matcher m = r.matcher(str);
while (m.find()) {
String data = m.group();
ans=ans+data;
}
return ans;
}
边栏推荐
猜你喜欢
随机推荐
抓包整理外篇fiddler———— 会话栏与过滤器[二]
Introduction to the implementation principle of rxjs observable filter operator
《剑指offer 04》二维数组查找
Vulnhub geminiinc V2
Nestjs configuration service, configuring cookies and sessions
Flutter Widget : Flow
Cacti monitors redis implementation process
Duplicate numbers in the array of sword finger offer 03
Simple factory and factory method mode
XML (DTD, XML parsing, XML modeling)
Differences between MySQL Union and union all
(construction notes) grasp learning experience
Momentum of vulnhub
【mysql专项】读锁和写锁
Go language to realize static server
(database authorization - redis) summary of unauthorized access vulnerabilities in redis
Basic knowledge of OpenGL (sort it out according to your own understanding)
Solutions to the failure of installing electron
Dart: about grpc (I)
Shardingsphere sub database and sub table < 3 >






![[learning notes] DP status and transfer](/img/5e/59c64d2fe08b89fba2d7e1e6de2761.png)


