프갤에서 어떤 언어 언급이 많이되는지 보고 싶은데..
c언어 언급하는걸 찾는게 넘 힘들다
이런거 좀 쉽게 찾는 스킬 같은게 있을까요?
내 코드 이거고
public class Test extends asdasd {
public static void main(String[] args) {
int i = 1;
String tit ="";
Map<String, Integer> map = new HashMap<String, Integer>();
try {
String output = "";
/* InputStreamReader reader = new InputStreamReader(System.in);
BufferedReader buff = new BufferedReader(reader);
*/
String url = "";
String selector = "";
selector = "a.icon_txt_n";
for(int k = 1 ; k < 50 ; k++) {
if(k%5==0)
System.out.println("되는중..."+k);
url = "http://gall.dcinside.com/board/lists/?id=programming&page="+k;</p><p><span style="white-space:pre"> Document doc = null;
Elements titles = null;
try {
doc = Jsoup.connect(url).get();
titles = doc.select(selector);
for (Element e : titles) {
tit= e.text();
if(tit.contains("자바")||tit.toLowerCase().contains("java")) {
if(map.get("java")!=null)
map.put("java", map.get("java")+1);
else
map.put("java", 1);
tit.replace("자바", "");
tit.replace("java", "");
tit.replace("JAVA", "");
}
if(tit.toLowerCase().contains("c++")) {
if(map.get("java")!=null)
map.put("c++", map.get("c++")+1);
else
map.put("c++", 1);
tit.replace("c++", "");
tit.replace("C++", "");
}
if(tit.toLowerCase().contains("c#")) {
if(map.get("c#")!=null)
map.put("c#", map.get("c#")+1);
else
map.put("c#", 1);
tit.replace("c#", "");
tit.replace("C#", "");
}
if(tit.toLowerCase().contains("c")) {
if(map.get("c")!=null) {
map.put("c", map.get("c")+1);
System.out.println("c 인 경우 : "+ e.text());
}
else {
map.put("c", 1);
System.out.println("c 인 경우 : "+ e.text());
}
}
}
// System.out.println(output);
}catch (Exception e) {
//continue;
}
}
}catch (Exception e) {
e.printStackTrace();
}
for(String key : map.keySet()) {
System.out.println(key+" : "+ map.get(key));
}
}
}
이거 말고도 e.text().split(" "); 써서 나오는 단어들 맵에 키값으로 넣어서 몇갠지 세보았는데
이것도 띄어쓰기 쓰는게 제각각이라 잘 안되더라고요
크롤링 하는 기법 같은거 있나여
댓글 0