1
geocaching.com을 크롤링하고 싶지만 코드와 같은 일부 데이터는 로그인 한 사용자 만 볼 수 있습니다. 고궁 박물원에서 "크롤러"을 사용하여 임과이 지금 생각 크롤러를 사용하여 로그인하지만 난 이미 로그인 폼의 이름을 가지고하는 방법 :NodeJS 크롤러가 사이트에 로그인
- ctl00 $ ContentBody $ tbUsername : 사용자
- ctl00 $ ContentBody $ tbPassword : "로그인을 +에서"여기
지금까지 내 코드입니다 :
var Crawler = require("crawler");
var url = require('url');
var mongoose = require("mongoose");
var Cache = require("./models/cache.js");
mongoose.connect("localhost:27017/Cache");
var removeTags = function(text){
return String(text).replace(/(<([^>]+)>)/ig,'');
};
var c = new Crawler({
maxConnections: 10,
skipDuplicates: true,
callback: function (error, result, $) {
if (result.request.uri.href.startsWith("http://www.geocaching.com/geocache/")) {
var cache = new Cache();
var id = removeTags($(".CoordInfoCode"));
Cache.count({
"_id": id
}, function (err, count) {
if (err)
return;
else if (count < 1) {
//Saving the data
}
});
}
if (result.headers['content-type'] == "text/html; charset=utf-8") {
if ($('a').length != 0) {
$('a').each(function (index, a) {
var toQueueUrl = $(a).attr('href');
process.nextTick(function() {
process.nextTick(function() {
c.queue(toQueueUrl);
})
});
});
}
}
}
});
c.queue('http://www.geocaching.com/seek/nearest.aspx?ul=Die_3sten_3');