<commit_before>require 'faraday'
require 'json'
require 'nokogiri'

module ChromeStoreSearch
  class StringUtility

    CHROME_STORE_URL = "https://chrome.google.com/webstore/category/apps"

    def self.gsub_continuation_commas(json_str)
      json_str.gsub(/,,,*/) do |commas_str|
        replace_str = ""
        (commas_str.size-1).times do |index|
          replace_str += ",\"\""
        end
        commas_str = replace_str + ","
      end
    end

    def self.get_pv
      conn = Faraday.new(:url => CHROME_STORE_URL) do |faraday|
        faraday.request  :url_encoded             # form-encode POST params
        faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
      end
      res = conn.get ''
      doc = Nokogiri::HTML(res.body)
      cws_session_data =  doc.xpath("//script[@id='cws-session-data']").first.content
      JSON.parse(cws_session_data)[-8]
    end
  end
end<commit_msg>fix search not work problem<commit_after>require 'faraday'
require 'json'
require 'nokogiri'

module ChromeStoreSearch
  class StringUtility

    CHROME_STORE_URL = "https://chrome.google.com/webstore/category/apps"

    def self.gsub_continuation_commas(json_str)
      json_str.gsub(/,,,*/) do |commas_str|
        replace_str = ""
        (commas_str.size-1).times do |index|
          replace_str += ",\"\""
        end
        commas_str = replace_str + ","
      end
    end

    def self.get_pv
      conn = Faraday.new(:url => CHROME_STORE_URL) do |faraday|
        faraday.request  :url_encoded             # form-encode POST params
        faraday.adapter  Faraday.default_adapter  # make requests with Net::HTTP
      end
      res = conn.get ''
      doc = Nokogiri::HTML(res.body)
      cws_session_data =  doc.xpath("//script[@id='cws-session-data']").first.content
      JSON.parse(cws_session_data)[-9]
    end
  end
end
{'fraction_non_alphanumeric': 0.11948331539289558, 'fraction_numerical': 0.002152852529601722, 'mean_word_length': 2.6237816764132553, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '2481215', 'n_tokens_mistral': 645, 'n_tokens_neox': 626, 'n_words': 115}