tdroadmap_merger/gettd.pl
changeset 24 8fb98cf0b1ac
parent 23 dbe87093a3ca
child 25 7a2c092f0fbf
equal deleted inserted replaced
23:dbe87093a3ca 24:8fb98cf0b1ac
     4 
     4 
     5 use IO::Socket; 
     5 use IO::Socket; 
     6 use Getopt::Long;
     6 use Getopt::Long;
     7 
     7 
     8 
     8 
     9 my $target_url;
     9 my $target_url; #target url for the roadmap
    10 my $tdomain;
    10 my $tdomain; #tag for the domain to be use in csv file
    11 my $csvfile;
    11 my $csvfile; #output csv file name
       
    12 my $authon= '';	; #does it require authorisation? default is false
    12 
    13 
    13 sub getpage
    14 sub getpage
    14 {
    15 {
    15 	#arguments
    16 	#arguments
    16 	($page,$host,$auth,$myfile)=@_;
    17 	($page,$host,$auth,$myfile)=@_;
    21 	
    22 	
    22 	
    23 	
    23 	$port = "http(80)";
    24 	$port = "http(80)";
    24 	$getmess = "GET " . $page ." HTTP/1.1\n" . $auth;
    25 	$getmess = "GET " . $page ." HTTP/1.1\n" . $auth;
    25 
    26 
    26 	print "sending message - $getmess\n";
    27 	print "INFO - sending message - $getmess\n";
    27 	print outputfile "$getmess\n\n";
    28 	print outputfile "$getmess\n\n";
    28 
    29 
    29 	$sock = IO::Socket::INET->new 	
    30 	$sock = IO::Socket::INET->new 	
    30 		(
    31 		(
    31 		 PeerAddr => $host,   PeerPort => $port,  Proto => 'tcp', 
    32 		 PeerAddr => $host,   PeerPort => $port,  Proto => 'tcp', 
   110 	foreach (@releases) {
   111 	foreach (@releases) {
   111 		
   112 		
   112 		$exp="\\<h2\\>.*?\\>".$_;
   113 		$exp="\\<h2\\>.*?\\>".$_;
   113 		
   114 		
   114 		if ($roadmap =~ m /($exp)/sg) { 
   115 		if ($roadmap =~ m /($exp)/sg) { 
   115 			print "Found entry for $_ \n";
   116 			print "PASS - Found entry for $_ \n";
   116 			$relroad =$';	
   117 			$relroad =$';	
   117 			
   118 			
   118 			if ($relroad =~ m /(.*?)\<h2/sg) { $relroad =$1;}
   119 			if ($relroad =~ m /(.*?)\<h2/sg) { $relroad =$1;}
   119 			$i=0;	
   120 			$i=0;	
   120 			while ($relroad=~ m/\<h3\>.*\>(.*?)\<.*<\/h3/g) {
   121 			while ($relroad=~ m/\<h3\>.*\>(.*?)\<.*<\/h3/g) {
   148 
   149 
   149 #help print
   150 #help print
   150 sub printhelp
   151 sub printhelp
   151 {
   152 {
   152 
   153 
   153 	print "\n\n version 0.2 
   154 	print "\n\n version 0.3 
   154 	\ngettd.pl -t=url -d=domain \nrequired parameters:\n\t -t url containing the technology domain roadmap\n\t -d the technology domain name
   155 	\ngettd.pl -t=url -d=domain \nrequired parameters:\n\t -t url containing the technology domain roadmap\n\t -d the technology domain name
   155 	\n Optional parameters\n\t-o filename ,the output is logged into the output.csv file by default\n\t-h for help";
   156 	\n Optional parameters\n\t-o filename ,the output is logged into the output.csv file by default\n\t-h for help
       
   157 	\n\t-a setup authorisation by cookie follow instructions in http://developer.symbian.org/wiki/index.php/Roadmap_merger_script#Cookies";
   156 	exit;
   158 	exit;
   157 }
   159 }
   158 
   160 
   159 
   161 
   160 #process command line options
   162 #process command line options
   163 
   165 
   164 
   166 
   165   my $help;
   167   my $help;
   166 
   168 
   167 
   169 
   168   GetOptions('h' => \$help,'t=s'=> \$target_url, 'd=s' => \$tdomain , 'o=s' => \$csvfile);
   170   GetOptions('h' => \$help,'t=s'=> \$target_url, 'd=s' => \$tdomain , 'o=s' => \$csvfile, 'a' => \$authon);
   169 
   171 
   170   if ($help) {
   172   if ($help) {
   171     printhelp;
   173     printhelp;
   172   }
   174   }
   173 
   175 
   188 
   190 
   189  if (not $csvfile) {
   191  if (not $csvfile) {
   190 	$csvfile="output.csv";
   192 	$csvfile="output.csv";
   191  }
   193  }
   192  print "\nINFO-output recorded in $csvfile \n";
   194  print "\nINFO-output recorded in $csvfile \n";
   193         
   195 
       
   196 
       
   197 
       
   198      
   194 
   199 
   195 
   200 
   196 
   201 
   197 }
   202 }
   198 #main
   203 #main
   199 $/ = " ";
   204 $/ = " ";
   200 
   205 cmd_options();
   201 #file containing login details from http cookie
   206 
   202 $mycookie = loadfile("mycookie.txt");
   207 if ($authon) {
   203 
   208 	#file containing login details from http cookie
   204 #$auth ="Authorization: Basic Zm91bmRhdGlvbjp0ZXN0MA==";
   209 	$mycookie = loadfile("mycookie.txt");
   205 $auth = "Cookie: " . $mycookie ;
   210 
       
   211 	$auth = "Cookie: " . $mycookie ;
       
   212 }
   206 
   213 
   207 #foundation releases - add as required
   214 #foundation releases - add as required
   208 @releases=("Symbian\\^2","Symbian\\^3","Symbian\\^4");
   215 @releases=("Symbian\\^2","Symbian\\^3","Symbian\\^4");
   209 
   216 
   210 
   217 
   211 $host1 = "developer.symbian.org";
   218 $host1 = "developer.symbian.org";
   212 
   219 
   213 
   220 
   214 cmd_options();
   221 
   215 
   222 
   216 getpage($target_url, $host1, $auth, "debug.txt");
   223 getpage($target_url, $host1, $auth, "debug.txt");
   217 td_roadmap("debug.txt" , $csvfile, $tdomain ,@releases);
   224 td_roadmap("debug.txt" , $csvfile, $tdomain ,@releases);