Wikipedia talk:WikiProject U.S. Roads/Redirects/Texas/Farm to Market and Ranch to Market Roads

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia
WikiProject iconU.S. Roads: Texas Project‑class
WikiProject iconThis page is within the scope of the U.S. Roads WikiProject, an attempt to build a comprehensive and detailed guide to state highways and other major roads in the United States. If you would like to participate, you can edit the article attached to this page, or visit the project page, where you can join the project and/or contribute to the discussion.
ProjectThis page does not require a rating on the project's quality scale.
Locations
 Texas  
 
WikiProject iconUnited States: Texas Project‑class
WikiProject iconThis page is within the scope of WikiProject United States, a collaborative effort to improve the coverage of topics relating to the United States of America on Wikipedia. If you would like to participate, please visit the project page, where you can join the ongoing discussions.
ProjectThis page does not require a rating on Wikipedia's content assessment scale.
Taskforce icon
This page is supported by WikiProject Texas.

Writing a script[edit]

I could probably write a script to check each of them remove the ones that aren't listed. Options for automatic removal might include <!-- commenting them out -->, striking them out, or moving them to a separate section or page to be manually examined, just in case they are false negatives. — Apr. 25, '06 [12:53] <freakofnurxture|talk>

Script[edit]

I wrote a script to validate this list by checking TxDOT. Because I don't expect to continue maintaing this page, here is the perl script if anyone wants to re-check in the future.--Svgalbertian (talk) 17:58, 19 October 2010 (UTC)[reply]

#!/usr/bin/perl
use strict;
use LWP::Simple;
use LWP::UserAgent;
use HTTP::Request;
use HTTP::Response;

# Highway record URLs
my %roadURL = (
        'FM' => 'http://www.dot.state.tx.us/tpp/hwy/fm%subdir%/fm%route%.htm',
        'RM' => 'http://www.dot.state.tx.us/tpp/hwy/rm/rm%route%.htm',
        'UR' => 'http://www.dot.state.tx.us/tpp/hwy/ur/ur%route%.htm',
);

# Output files
open ( TXTFILE, ">wikitext.txt" ) || die ("you die now!");

# Cycle through all the road pages
for (my $i = 1; $i < 4000; $i++) {

 my %title = ();
 my $subdir = '';

 if ($i >= 500) {
   use integer;
   $subdir = sprintf("%04d", ($i / 500) * 500);
 }

 # Grab all the highway records from the internet
 my $paddednum = sprintf("%04d", $i);

 foreach my $routetype (keys (%roadURL)) {
   my $URL = $roadURL{$routetype};

   (my $currenturl = $URL) =~s/\%route\%/$paddednum/g;
   $currenturl =~s/\%subdir\%/$subdir/g;
   my $contents = &getPage($currenturl);

   $contents =~ m/<title>(.*?)<\/title>/;
   $title{$routetype} = $1;
 }

 # Does the FM route exist? If so is it also an UR?
 if($title{'FM'} !~ m/Page Not Found/) {
  if($title{'UR'} =~ m/Page Not Found/) {
	print "*{{txfm|$i}}\n";
        print TXTFILE "*{{txfm|$i}}\n";
  }
  else {
	print "*{{txfm|$i|u}}\n";
        print TXTFILE "*{{txfm|$i|u}}\n";
  }   	
 }

 # Does the RM route exist? If so is it also an UR?
 if($title{'RM'} !~ m/Page Not Found/) {
  if($title{'UR'} =~ m/Page Not Found/) {
	print "*{{txrm|$i}}\n";
        print TXTFILE "*{{txrm|$i}}\n";
  }
  else {
	print "*{{txrm|$i|u}}\n";
        print TXTFILE "*{{txrm|$i|u}}\n";
  }   	
 }
}

# Close the files
close (TXTFILE);

use strict;
sub getPage {
  # Function to get a webpage
  my($currenturl) = @_;
  my $contents;

  my $browser = LWP::UserAgent->new();
  $browser->timeout(10);

  my $request = HTTP::Request->new(GET => $currenturl);
  my $response = $browser->request($request);

  $contents = $response->content();

  return $contents;
}