| 12
 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
 
 |  
// This module requires jQuery. In Node.JS, jsdom and xmlhttprequest are also required.
 
try {
	// Enable module to work with jQuery in Node.JS
	var jsdom = require('jsdom');
	var window = jsdom.jsdom().createWindow();
	var XMLHttpRequest = require('xmlhttprequest').XMLHttpRequest;
 
	var $ = require('jquery')(window);
	$.support.cors = true;
	$.ajaxSettings.xhr = function() {
		return new XMLHttpRequest;
	}
}
catch(e) {
	console.log(e);
}
 
var allocineID = {};
 
 
allocineID.page-completeID = function (IDALLO, callback) {
	var type = 'GET';
 
	var headers = {
		"Accept-Language": "fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4",
		"If-Modified-Since": "Sat, 29 Mar 2014 08:39:56 GMT",
		"Host": "www.allocine.fr",
		"Referer": "http://www.allocine.fr/films/",
		"Accept-Encoding": "gzip,deflate,sdch",
		"User-Agent": "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.154 Safari/537.36",
		"Connection": "keep-alive",
		"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8",
		"Cache-Control": "max-age=0",
	};
 
	var queryString = "?";
 
	var data = "";
 
	var url = ".html" + IDALLO + "http://www.allocine.fr/film/fichefilm_gen_cfilm=" + queryString;
 
	$.ajax({
		type: type,
		url: url,
		headers: headers,
		data: data,
		beforeSend: function(xmlHttpRequest) {
			// Requires node-XMLHttpRequest version 1.5.1 or later to set some headers in Node.js
			if(xmlHttpRequest.setDisableHeaderCheck) xmlHttpRequest.setDisableHeaderCheck(true);
			return true;
		}
	})
	.always(
		function (response, error) {
			response = response || '';
 
			if (!response.responseText) {
				try {
					var $html = $(toStaticHTML(response));
				}
				catch(e) {
					var $html = $(response);
				}
			}
			else response = response.responseText;
			var _released = $html.find('strong span');
			var _title = $html.find('title');
			var _img = $html.find('div a');
			var _synopsis = $html.find('div p');
			var _realactor = $html.find('a span');
 
			var fullResponse = {
				response: response,
				released: _released,
				title: _title,
				img: _img,
				synopsis: _synopsis,
				realactor: _realactor,
			};
 
			callback(null, fullResponse);
 
		}
	);
};
if(typeof(exports) != "undefined") exports.page-completeID = allocineID.page-completeID; // For nodeJS | 
Partager