2016-08-05 15 views
0

解決:似乎孟買大學使用不同的服務器爲 不同的結果,我注意到了。NodeJS request.post方法問題

我正在寫一個腳本來直接從我的大學網站上檢索我的結果。但是我在NodeJS的「request」模塊中遇到了「request.post」方法的問題。

這裏是我的代碼

var cheerio = require('cheerio'); 
var request = require('request'); 
request.post({ 
    headers: {'content-type' : 'application/x-www-form-urlencoded', 'content-length':69}, 
    url:  'http://results.mu.ac.in/get_resultc.php', 
    body: "exam_id=4050&exam_year=2016&exam_month=MAY&seat_no=45280208&submit=Go" 
    }, function(error, response, body){ 
     var $ = cheerio.load(body); 
     console.log($('html').text()); 
     var result = $('b').text(); 
     console.log(result); 
}); 

我得到以下輸出

.. 
.. 
No Such Seat No!! 

但是,如果我有打嗝發送相同的數據後,我得到了正確的輸出如下圖所示的形象。

Link to image

請讓我知道我在哪裏出了問題,什麼可以做的。謝謝。

注意:顯示的查詢是測試查詢,與我的考試編號 或座位號碼無關。

+0

那麼,在你的例子中的數據發佈到該網址返回'沒有這樣的座位沒有!!'。我嘗試使用Firefox和HttpRequester插件,並返回上述內容。 –

回答

0

在你的代碼上面點的網址:

url:  'http://results.mu.ac.in/get_resultc.php', 

但圖像點:

url:  'http://results.mu.ac.in/get_resultb.php', 

「get_result b .PHP」

發帖get_resultb.php yeilds:

Results for B.E.Degree (COMPUTER ENGG.) (SEM-VIII) (CBSGS) held on MAY 2016 

The result of seat number 45280208 is PassedCongratulations. 
+0

我沒注意到。我準備了以前的結果網址上的腳本。感謝您提出。 – computers