Add 'json.rb'

This commit is contained in:
Netflix 2021-03-08 02:49:57 +01:00
parent 03144f711d
commit dd15b52143
1 changed files with 53 additions and 0 deletions

53
json.rb Normal file
View File

@ -0,0 +1,53 @@
require 'json'
require 'date'
require 'lda-ruby'
require 'lingua/stemmer'
require 'textoken'
require 'stopwords'
require_relative 'lib'
class Clean
def initialize(line)
@line = line
end
def line
@line
end
def cleanize
corpus = Lda::Corpus.new
f = Stopwords::Snowball::Filter.new "en"
cleaned_post = line.downcase
text_token = Textoken(cleaned_post, exclude: 'punctuations').tokens
filtered = f.filter(text_token)
return filtered
end
end
class Json
def initialize
@date = DateTime.now.strftime("%m/%d/%Y")
end
def date
@date
end
def save_file
if !File.exists?("fucking_Work.json")
File.open(File.join("fucking_Work.json"), "w") { |file| file.write("{}") }
end
@f_json = []
json = JSON.parse(File.read("fucking_Work.json"))
File.readlines("DarknetMarketsNoobs_urls.txt").each do |l|
curl = Config.new.get_body
curl = curl.gsub(".onion", ".onion#{l}")
stdout, status = Open3.capture3(curl)
page = Nokogiri::HTML(stdout)
out = page.xpath("/html/body/div/div[2]/div[2]/div/div[2]/div").text.strip
c = Clean.new(out).cleanize
@f_json << c.join(" ")
end
p @f_json
json[date] += @f_json
File.open(File.join("fucking_Work.json"), "w") { |file| file.write(JSON.pretty_generate(json)) }
end
end
Json.new().save_file