Request: كيف يمكنني الوصول إلى عنوان url الخاص بالطلب بعد إعادة التوجيه؟

تم إنشاؤها على ٤ مارس ٢٠١٤  ·  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 كومينتر

look in response.request.redirects ، فهو يحتوي على مجموعة من عناوين url الخاصة بإعادة التوجيه.

تضمين التغريدة لسوء الحظ ، إنها مجموعة فارغة.

هذا يعطيني ما أحتاجه 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 التقييمات