1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
| var request = require('request')
var Iconv1 = require('iconv').Iconv
var cheerio = require('cheerio');
request({uri: 'http://cleanair.seoul.go.kr/air_city.htm?method=measure', encoding: 'binary'},
function(err, response, body) {
var strContents = new Buffer(body, 'binary')
iconv = new Iconv1('euc-kr', 'UTF8')
strContents = iconv.convert(strContents).toString()
var $ = cheerio.load(strContents);
console.log( '\n<'+$('.ft_point1', '.graph_h4').text()+'>');
$('tbody tr','.tbl2').each(function() {
var strArea=$(this).find("td").eq(0).html().replace(/\s+/, "");
strArea = strArea.replace(/(\r\n|\n|\r)/gm,"");
strArea = strArea.replace(/\s+/, "");
if(strArea=="금천구"||strArea=="강남구"||strArea=="양천구") {
var strVal10 = $(this).find("td").eq(1).html().replace(/\s+/, "");
strVal10 = strVal10.replace(/(\r\n|\n|\r)/gm, "");
strVal10 = strVal10.replace(/\s+/, "");
var strVal2_5 = $(this).find("td").eq(2).html().replace(/\s+/, "");
strVal2_5 = strVal2_5.replace(/(\r\n|\n|\r)/gm, "");
strVal2_5 = strVal2_5.replace(/\s+/, "");
var strStatus = $(this).find("td").eq(7).html().replace(/\s+/, "");
strStatus = strStatus.replace(/(\r\n|\n|\r)/gm, "");
strStatus = strStatus.replace(/\s+/, "");
var strDeterminationFactor = $(this).find("td").eq(8).html().replace(/\s+/, "");
strDeterminationFactor = strDeterminationFactor.replace(/(\r\n|\n|\r)/gm, "");
strDeterminationFactor = strDeterminationFactor.replace(/\s+/, "");
var strVal9 = $(this).find("td").eq(9).html().replace(/\s+/, "");
strVal9 = strVal9.replace(/(\r\n|\n|\r)/gm, "");
strVal9 = strVal9.replace(/\s+/, "");
strVal9 = strVal9.replace("</sub>", "");
strVal9 = strVal9.replace("<sub>2", "²");
console.log('-' + strArea + ': PM10=' +
strVal10+ ' / PM2.5=' +strVal2_5 + ' / ' +
strStatus+ ' / ' + '결정물질:'+
strVal9 +' ['+strDeterminationFactor +']');
}
})
request({uri: 'http://cleanair.seoul.go.kr/main.htm', encoding: 'binary'},
function(err, response, body) {
var strContents = new Buffer(body, 'binary')
iconv = new Iconv1('euc-kr', 'UTF8')
strContents = iconv.convert(strContents).toString()
var $ = cheerio.load(strContents);
console.log( '\n* 서울 미세먼지 평균 농도 : '+$('.average ', '.w154').text() );
$('.al_c').each(function() {
var strTemper=$(this).find("td").eq(0).html().replace(/\s+/, "");
strTemper = strTemper.replace(/(\r\n|\n|\r)/gm,"");
strTemper = strTemper.replace(/\s+/, "");
strTemper = strTemper.replace("°C", "℃");
console.log('* 온도 : ' + strTemper );
var strHum=$(this).find("td").eq(1).html().replace(/\s+/, "");
strHum = strHum.replace(/(\r\n|\n|\r)/gm,"");
strHum = strHum.replace(/\s+/, "");
console.log('* 습도 : ' + strHum );
var strWinDest=$(this).find("td").eq(2).html().replace(/\s+/, "");
strWinDest = strWinDest.replace(/(\r\n|\n|\r)/gm,"");
strWinDest = strWinDest.replace(/\s+/, "");
console.log('* 풍향 : ' + strWinDest );
var strWin=$(this).find("td").eq(3).html().replace(/\s+/, "");
strWin = strWin.replace(/(\r\n|\n|\r)/gm,"");
strWin = strWin.replace(/\s+/, "");
console.log('* 풍속 : ' + strWin );
})
})
})
|
현재 npm install iconv를 하면 오류가 나는 것같은데.. 어떻게 하면좋을까요.. ㅠ
답글삭제쓰신글 다 읽구 왔습니당.. ㅎㅎ 굉장하신분이더군용 ㅎㅎ
답글삭제저두 euc-kr로 이루어진 html을 스크래핑할려구 하는데 한글깨짐오류가 떠가지구용.. ㅠ.ㅠ 알려주세용 ㅎㅎ
답글삭제안녕하세요, 정확히 어떤 오류인지는 모르겠지만 혹시 다음과 같이 libtool: unrecognized option `-static' 오류인 경우라면, 다음처럼 libtool의 경로를 확인해보시고, /usr/local/bin/libtool 은 삭제후 npm install을 다시 시도해보시기 바랍니다.
답글삭제kojh-mb-pro:seoul_dust kojunghyun$ npm install
|
> iconv@2.1.10 install /Users/kojunghyun/kojh/MyDev_MBP/NodeJs_Dev/seoul_dust/node_modules/iconv
> node-gyp rebuild
2015-08-24 00:17:50.030 xcodebuild[75668:37424770] [MT] PluginLoading: Required plug-in compatibility UUID 7FDF5C7A-131F-4ABB-9EDC-8C5F8F0B8A90 for plug-in at path '~/Library/Application Support/Developer/Shared/Xcode/Plug-ins/Unity4XC.xcplugin' not present in DVTPlugInCompatibilityUUIDs
CC(target) Release/obj.target/libiconv/deps/libiconv/lib/iconv.o
LIBTOOL-STATIC Release/iconv.a
libtool: unrecognized option `-static'
libtool: Try `libtool --help' for more information.
make: *** [Release/iconv.a] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:810:12)
...
kojh-mb-pro:seoul_dust kojunghyun$ which -a libtool
/usr/local/bin/libtool
/usr/bin/libtool
kojh-mb-pro:seoul_dust kojunghyun$ sudo rm -f /usr/local/bin/libtool
답변 정말 감사합니다. ㅎㅎㅎ 담번에 libtool에러가 뜨면 이렇게 처리해야겠네요 ㅎㅎ
삭제그문제가 아니라서용.. ㅎㅎ
http://stackoverflow.com/questions/23800562/global-npm-install-failing-on-osx
이링크보고 무사히 해결했습니다. ㅎㅎ