196
196
sub init_user_agent() {
197
197
# Change HTTP Headers to make canalsat-reunion.com happy
198
$XMLTV::Get_nice::ua->default_headers->push_header('Accept'=>'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
199
$XMLTV::Get_nice::ua->default_headers->push_header('Accept-Language'=>'fr-fr,fr;q=0.8,en-us;q=0.5,en;q=0.3');
200
$XMLTV::Get_nice::ua->default_headers->push_header('Accept-Encoding'=>'gzip,deflate');
201
$XMLTV::Get_nice::ua->default_headers->push_header('Accept-Charset'=>'ISO-8859-1,utf-8;q=0.7,*;q=0.7');
202
$XMLTV::Get_nice::ua->default_headers->push_header('Keep-Alive'=>'300');
203
$XMLTV::Get_nice::ua->default_headers->header('Connection'=>'keep-alive');
198
#$XMLTV::Get_nice::ua->default_headers->push_header('Accept'=>'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8');
199
#$XMLTV::Get_nice::ua->default_headers->push_header('Accept-Language'=>'fr-fr,fr;q=0.8,en-us;q=0.5,en;q=0.3');
200
#$XMLTV::Get_nice::ua->default_headers->push_header('Accept-Encoding'=>'gzip,deflate');
201
#$XMLTV::Get_nice::ua->default_headers->push_header('Accept-Charset'=>'ISO-8859-1,utf-8;q=0.7,*;q=0.7');
202
#$XMLTV::Get_nice::ua->default_headers->push_header('Keep-Alive'=>'300');
203
#$XMLTV::Get_nice::ua->default_headers->header('Connection'=>'keep-alive');
204
204
#$XMLTV::Get_nice::ua->agent("Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9b5) Gecko/2008041514 Firefox/3.0b5");
207
my $cookies = HTTP::Cookies->new(
208
file => "$ENV{HOME}/.xmltv/tv_grab_re.cookies",
214
$XMLTV::Get_nice::ua->cookie_jar($cookies);
207
#my $cookies = HTTP::Cookies->new(
208
# file => "$ENV{HOME}/.xmltv/tv_grab_re.cookies",
210
# ignore_discard => 1,
214
#$XMLTV::Get_nice::ua->cookie_jar($cookies);
215
215
# $cookies->load();
217
217
#$XMLTV::Get_nice::ua->default_headers->push_header('Referer'=>);
218
my $html = $XMLTV::Get_nice::ua->get("http://www.canalsat-reunion.com");
219
$cookies->extract_cookies($html);
218
#my $html = $XMLTV::Get_nice::ua->get("http://www.canalsat-reunion.com");
219
#$cookies->extract_cookies($html);
220
220
#print '1: '; $cookies->as_string();
222
$XMLTV::Get_nice::ua->default_headers->header('Referer'=>'http://www.canalsat-reunion.com');
223
$html = $XMLTV::Get_nice::ua->get("http://fw-web.canalreunion.net/347.0.html");
222
#$XMLTV::Get_nice::ua->default_headers->header('Referer'=>'http://www.canalsat-reunion.com');
223
#$html = $XMLTV::Get_nice::ua->get("http://fw-web.canalreunion.net/347.0.html");
224
224
#$cookies->extract_cookies($html);
225
225
#print '1a: '; $cookies->as_string();
227
$XMLTV::Get_nice::ua->default_headers->header('Referer'=>'http://fw-web.canalreunion.net/347.0.html');
228
$XMLTV::Get_nice::ua->cookie_jar($cookies);
229
$html = $XMLTV::Get_nice::ua->get("http://fw-web.canalreunion.net/408.0.html");
227
#$XMLTV::Get_nice::ua->default_headers->header('Referer'=>'http://fw-web.canalreunion.net/347.0.html');
228
#$XMLTV::Get_nice::ua->cookie_jar($cookies);
229
#$html = $XMLTV::Get_nice::ua->get("http://fw-web.canalreunion.net/408.0.html");
230
230
#$cookies->extract_cookies($html);
231
231
#print '2: '; $cookies->as_string();
233
$XMLTV::Get_nice::ua->default_headers->header('Referer' => 'http://fw-web.canalreunion.net/408.0.html');
233
#$XMLTV::Get_nice::ua->default_headers->header('Referer' => 'http://fw-web.canalreunion.net/408.0.html');
234
234
# post normalement
235
$XMLTV::Get_nice::ua->cookie_jar($cookies);
236
$html = $XMLTV::Get_nice::ua->post("http://fw-web.canalreunion.net/552.0.html?&no_cache=1&programme[fuseauChoix]=2&programme[validation_choifuseaux]=Envoyer");
235
#$XMLTV::Get_nice::ua->cookie_jar($cookies);
236
# my $html = $XMLTV::Get_nice::ua->post("http://fw-web.canalreunion.net/552.0.html",
238
# 'programme[fuseauChoix]'=>2,
239
# 'programme[jour]'=>"12/12/2008",
240
# 'programme[horaires]'=>"6.",
241
# 'programme[chaine]'=>42,
242
# 'programme[genre]'=>"",
244
# 'programme[pdf]'=>"",
245
# 'programme[confirmation_choixfuseau]'=>"Envoyer");
237
246
#$cookies->extract_cookies($html);
238
247
#print '3: '; $cookies->as_string();
240
$XMLTV::Get_nice::ua->default_headers->header('Referer' => 'http://fw-web.canalreunion.net/552.0.html&no_cache=1');
241
$XMLTV::Get_nice::ua->cookie_jar($cookies);
242
$html = $XMLTV::Get_nice::ua->get("http://fw-web.canalreunion.net/552.0.html?&no_cache=1&programme[fuseauChoix]=2&programme[validation_choifuseaux]=Envoyer");
249
#$XMLTV::Get_nice::ua->default_headers->header('Referer' => 'http://fw-web.canalreunion.net/552.0.html&no_cache=1');
250
#$XMLTV::Get_nice::ua->cookie_jar($cookies);
251
#$html = $XMLTV::Get_nice::ua->get("http://fw-web.canalreunion.net/552.0.html?&no_cache=1&programme[fuseauChoix]=2&programme[validation_choifuseaux]=Envoyer");
243
252
#$cookies->extract_cookies($html);
244
253
#print '4: '; $cookies->as_string();
246
254
#print $html->content;
259
sub post_nice_tree ($;%) {
264
require HTML::TreeBuilder;
265
my $html = $XMLTV::Get_nice::ua->post($url, $form);
267
my $t = new HTML::TreeBuilder;
268
$t->parse($html->content) or die "cannot parse content of $url\n";
251
273
sub get_channels_list($) {
390
412
# the start tag of programs for this day
391
413
my $start = DateCalc($today, "+ $n days");
393
my $url_day = UnixDate($start, "%d%%2F%m%%2F%Y");
415
my $url_day = UnixDate($start, "%d/%m/%Y");
396
my $url = "http://fw-web.canalreunion.net/552.0.html?&no_cache=1&";
397
$url .= "programme[jour]=".$url_day."&";
398
$url .= "programme[horaires]=6.&"; # whole day
399
$url .= "programme[chaine]=".$idchaine."&";
400
$url .= "programme[genre]=&";
401
$url .= "Submit=OK&";
402
$url .= "programme[pdf]=";
418
my $url = "http://fw-web.canalreunion.net/552.0.html";
421
$form{'programme[confirmation_choixfuseau]'} = "Envoyer";
422
$form{'programme[pdf]'} = "";
423
$form{'Submit'} = "OK";
424
$form{'programme[genre]'} = "";
425
$form{'programme[chaine]'} = $idchaine;
426
$form{'programme[horaires]'} = 6.; # whole day
427
$form{'programme[jour]'} = $url_day;
428
$form{'programme[fuseauChoix]'} = 2;
429
$form{'no_cache'} = 1;
404
432
# get request and parse
405
my $html = get_nice_tree $url;
433
my $html = post_nice_tree($url, \%form);
406
434
$html->objectify_text();