<commit_before>require 'open-uri'
require 'nokogiri'

module TransitionConfig
  class TNATimestamp
    TNA_BASE_URL = "http://webarchive.nationalarchives.gov.uk"

    def initialize(hostname)
      @hostname = hostname
    end

    def find
      begin
        response = open("#{TNA_BASE_URL}/+/http://#{@hostname}")
      rescue OpenURI::HTTPError
        puts "Couldn't find a crawl. Trying HTTPS..."
        begin
          response = open("#{TNA_BASE_URL}/+/https://#{@hostname}")
        rescue OpenURI::HTTPError
          $stderr.puts("TNA don't appear to have crawled this (yet) #{@hostname} Try the aliases?")
          return nil
        end
      end

      doc = Nokogiri::HTML(response)
      most_recent_crawl_link = doc.xpath('//*[@id="header"]/div/div[1]/ul/li[6]/a').last
      url = URI.parse(most_recent_crawl_link['href'])
      url.path.split('/')[1]
    end
  end
end<commit_msg>Don't error if the timestamp can't be found<commit_after>require 'open-uri'
require 'nokogiri'

module TransitionConfig
  class TNATimestamp
    TNA_BASE_URL = "http://webarchive.nationalarchives.gov.uk"

    def initialize(hostname)
      @hostname = hostname
    end

    def find
      begin
        response = open("#{TNA_BASE_URL}/+/http://#{@hostname}")
      rescue OpenURI::HTTPError
        puts "Couldn't find a crawl. Trying HTTPS..."
        begin
          response = open("#{TNA_BASE_URL}/+/https://#{@hostname}")
        rescue OpenURI::HTTPError
          $stderr.puts("TNA don't appear to have crawled this (yet) #{@hostname} Try the aliases?")
          return nil
        end
      end

      doc = Nokogiri::HTML(response)
      most_recent_crawl_link = doc.xpath('//*[@id="header"]/div/div[1]/ul/li[6]/a').last

      return nil unless most_recent_crawl_link

      url = URI.parse(most_recent_crawl_link['href'])
      url.path.split('/')[1]
    end
  end
end
{'fraction_non_alphanumeric': 0.13807753584705257, 'fraction_numerical': 0.003186404673393521, 'mean_word_length': 2.7086614173228347, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4425594', 'n_tokens_mistral': 641, 'n_tokens_neox': 630, 'n_words': 130}