Class: Utils::ENVData

Inherits:
Object
  • Object
show all
Defined in:
lib/utils/constants.rb

Overview

constants that will be used in by search / scraping scripts

Constant Summary collapse

MARKET_CACHE =
'./market_cache'
BDO_CODEX_CACHE =
'./bdo_codex_cache'
ERROR_LOG =
'./error.log'
'__RequestVerificationToken=aVYGQPovG8EI6bRIagh8tbHJUhZlM-nH3UKVQaV9R9N0vODzmWcB747BHEsHaphwANvzsaNi5TCPlB-72-e1LadqAlL-bdkDkTqVh4gMnu81'
RVT =

rubocop:disable Layout/LineLength

'__RequestVerificationToken=yWbqJmiU4wcp2IRQGkbDfqMFs2fjCYx4UqVxg4umK8CvdbLhweMLZ1es-4SFWD8J1UfoqwbaQyo_YuzAkSzHWY8Wjyx4ttwZBvtu_pd--9U1'
WORLD_MARKET_LIST =

rubocop:disable Layout/LineLength

'/GetWorldMarketList'
MARKET_SUB_LIST =
'/GetWorldMarketSubList'
MARKET_SEARCH_LIST =
'/GetWorldMarketSearchList'
MARKET_SELL_BUY_INFO =
'/GetItemSellBuyInfo'
MARKET_HOT_LIST =
'/GetWorldMarketHotList'
MARKET_WAIT_LIST =
'/GetWorldMarketWaitList'
REQUEST_OPTS =
{
  method: 'post',
  central_market_headers: {
    'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
    'User-Agent':
      'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
    Cookie: COOKIE,
    Dnt: '1',
    'x-cdn': 'Imperva'
  },
  bdo_codex_headers: {
    'User-Agent':
      'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36',
    Dnt: '1',
    accept: 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7'
  }
}.freeze

Class Method Summary collapse

Class Method Details

.get_bdo_codex_headers(item_id, region) ⇒ Object

TODO: wip…



119
120
121
122
123
124
125
126
127
128
# File 'lib/utils/constants.rb', line 119

def self.get_bdo_codex_headers(item_id, region)
  item_url = "https://bdocodex.com/#{region}/item/#{item_id}"
  cookie_string = "bddatabaselang=#{region}"
  if rand > 0.5
    REQUEST_OPTS[:central_market_headers]
    { **REQUEST_OPTS[:bdo_codex_headers], 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', Cookie: cookie_string }
  else
    { **REQUEST_OPTS[:bdo_codex_headers], 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36', Cookie: cookie_string }
  end
end

.get_central_market_headers(incap_cookie = '') ⇒ Object



130
131
132
133
134
135
136
137
138
# File 'lib/utils/constants.rb', line 130

def self.get_central_market_headers(incap_cookie = '')
  original_cookie = REQUEST_OPTS[:central_market_headers][:Cookie]
  if rand > 0.5
    REQUEST_OPTS[:central_market_headers]
    { **REQUEST_OPTS[:central_market_headers], 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36', Cookie: "#{original_cookie};#{incap_cookie}" }
  else
    { **REQUEST_OPTS[:central_market_headers], 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/134.0.0.0 Safari/537.36', Cookie: "#{original_cookie};#{incap_cookie}" }
  end
end


140
141
142
143
144
145
146
147
148
149
150
# File 'lib/utils/constants.rb', line 140

def self.get_incap_cookie(region_domain)
  new_expiry = Date.today + 365
  day = Time.now.strftime("%a")
  month = Time.now.strftime("%b")
  hour = rand(1..12)
  minute = rand(1..60)
  second = rand(1..60)

  # TODO: EXPERIMENTAL - figure out how to simulate incapsula data
  "visid_incap_2504212=xoYUIj+XR/acq/q6uc0RZyLI/2cAAAAAQUIPAAAAAAAMYr/xXVQYe6Eo4uVK+L6V; expires=#{day}, #{new_expiry.day} #{month} #{new_expiry.year} #{hour}:#{minute}:#{second} GMT; HttpOnly; path=/; Domain=.#{region_domain}; Secure; SameSite=None"
end

.get_root_url(region) ⇒ Object



152
153
154
# File 'lib/utils/constants.rb', line 152

def self.get_root_url(region)
  "https://#{CLIConstants::REGION_DOMAINS[region.to_sym]}/Home"
end