1
2
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
use strict;
use LWP::UserAgent;
use HTTP::Headers;
my $header = new HTTP::Headers;
$header->header("User-Agent" => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; .NET CLR 1.1.4322; .NET CLR 2.0.40607)');
$header->header("Accept-Language" => "de");
$header->header("Accept" => "*/*");
my $useragent = LWP::UserAgent->new('timeout' => 50);
my $initial_request = HTTP::Request->new('GET', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/MainMenu', $header);
my $cookieid = '';
my $initial_response = $useragent->simple_request($initial_request);
if($initial_response->is_success())
{
if($initial_response->header('set-cookie') =~ m/JSESSIONID=([^;]+);/)
{
$cookieid = $1;
}
$header->header('Cookie', 'JSESSIONID=' . $cookieid);
my $search_header = $header;
$search_header->header('referer', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/MainMenu');
my $search_request = HTTP::Request->new('GET', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/freeword?freetext=&submit_find=%E6%A4%9C%E7%B4%A2%E9%96%8B%E5%A7%8B&chiku=36', $search_header);
print $search_request->as_string . "\n\n";
my $search_response = $useragent->simple_request($search_request);
if($search_response->is_success())
{
print "got main\n";
my $search_result_header = $header;
$search_result_header->header('referer', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/MainMenu');
my $search_result_request = HTTP::Request->new('GET', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/search_low.jsp?freetext=&submit_find=%E6%A4%9C%E7%B4%A2%E9%96%8B%E5%A7%8B&chiku=36', $search_result_header);
print $search_result_request->as_string . "\n\n";
my $search_result_response = $useragent->simple_request($search_result_request);
if($search_result_response->is_success())
{
print "got results\n";
open(OUTPUT, ">search.htm") || die $!;
print OUTPUT $search_result_response->content;
close(OUTPUT);
my $search_single_result_header = $header;
$search_single_result_header->header('referer', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/search_low.jsp?freetext=&submit_find=%E6%A4%9C%E7%B4%A2%E9%96%8B%E5%A7%8B&chiku=36');
my $search_single_result_request = HTTP::Request->new('GET', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/SimpleView?kikan=6510412', $search_single_result_header);
print $search_single_result_request->as_string . "\n\n";
my $search_single_result_response = $useragent->simple_request($search_single_result_request);
if($search_single_result_response->is_success())
{
print "got 1 result\n";
my $search_single_result_text_header = $header;
$search_single_result_text_header->header('referer', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/SimpleView?kikan=6510412');
my $search_single_result_text_request = HTTP::Request->new('GET', 'https://www.iryo.pref.tokushima.jp/iryou-kokai/SimpleView_Low.jsp', $search_single_result_header);
print $search_single_result_text_request->as_string . "\n\n";
my $search_single_result_text_response = $useragent->simple_request($search_single_result_text_request);
if($search_single_result_text_response->is_success())
{
print "got 1 text results\n";
open(OUTPUT, ">search1res.htm") || die $!;
print OUTPUT $search_single_result_text_response->content;
close(OUTPUT);
}
else
{
$search_result_response->status_line . "\n\n";
}
}
else
{
$search_single_result_response->status_line . "\n\n";
}
}
else
{
$search_result_response->status_line . "\n\n";
}
}
else
{
print $search_response->status_line . "\n";
}
}
else
{
print $initial_response->status_line . "\n";
}
aye. ich hab gerade lust gehabt. denke, das tut, was du willst. hab keinen freetext übergeben, dadurch kommen wohl mehr oder weniger alle. und ich parse den quelltext der results nicht, sondern hab das eine resultat hardcoded (kikan=6510412).
hth.