Request: ๋ฆฌ๋””๋ ‰์…˜ ํ›„ ์š”์ฒญ์˜ URL์— ์–ด๋–ป๊ฒŒ ์•ก์„ธ์Šคํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๊นŒ?

์— ๋งŒ๋“  2014๋…„ 03์›” 04์ผ  ยท  3์ฝ”๋ฉ˜ํŠธ  ยท  ์ถœ์ฒ˜: request/request

๋ฆฌ๋””๋ ‰์…˜๋œ ํ›„ ์š”์ฒญ์˜ URL์— ์•ก์„ธ์Šคํ•ด์•ผ ํ•ฉ๋‹ˆ๋‹ค. ์˜ˆ:

 function(err, resp,body){
            $ = cheerio.load(body);
            //console.log(jar.cookies);
            request.post({
                jar:jar,
                url:targetBaseURL+'/search.php?do=process',
                followAllRedirects: true,
                headers: {
                    'User-Agent': userAgent

                },
                form :{
                    's'             : '',
                    'do'            : 'process',
                    'searchthreadid': '0',
                    'query'         : '',
                    'titleonly'     : '0',

...
                proxy: 'http://127.0.0.1:8888'

            }, function(err, resp, body){
               console.log(resp.request.redirects); // array is empty
                $ = cheerio.load(body);
                $("[id*=post]").each(function(i, elem){

                    var title =$(elem).find('a strong');
                    if(!$(title).text().match(/livescores/i)) {
                        //console.log($(title).text().trim());
                        var post = $(elem).find('div > em');
                        //console.log($(post).text().trim());
                    }
                });

            })
        });

๊ฐ€์žฅ ์œ ์šฉํ•œ ๋Œ“๊ธ€

์ด๊ฒƒ์€ ๋‚ด๊ฐ€ ํ•„์š”ํ•œ ๊ฒƒ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. console.log(resp.request.uri.href);

์—ฌ๊ธฐ์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค - http://stackoverflow.com/questions/16687618/how-do-i-get-the-redirected-url-from-the-nodejs-request-module

๋ชจ๋“  3 ๋Œ“๊ธ€

response.request.redirects๋ฅผ ๋ณด๋ฉด ๋ฆฌ๋””๋ ‰์…˜ URL์˜ ๋ฐฐ์—ด์ด ์žˆ์Šต๋‹ˆ๋‹ค.

@spollack ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๋ถˆํ–‰ํžˆ๋„ ๋นˆ ๋ฐฐ์—ด์ž…๋‹ˆ๋‹ค.

์ด๊ฒƒ์€ ๋‚ด๊ฐ€ ํ•„์š”ํ•œ ๊ฒƒ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค. console.log(resp.request.uri.href);

์—ฌ๊ธฐ์—์„œ ์ฐพ์„ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค - http://stackoverflow.com/questions/16687618/how-do-i-get-the-redirected-url-from-the-nodejs-request-module

์ด ํŽ˜์ด์ง€๊ฐ€ ๋„์›€์ด ๋˜์—ˆ๋‚˜์š”?
0 / 5 - 0 ๋“ฑ๊ธ‰