Skip to content

Instantly share code, notes, and snippets.

@rudkovskyi
Last active Feb 27, 2018
Embed
What would you like to do?
require_relative 'request'
require 'json'
module Requests
class Wordpress
WEBSITE_URL = 'https://public-api.wordpress.com/rest/v1.1/sites/xxx/stats?http_envelope=1'.freeze
def initialize
super(WEBSITE_URL)
chrome!
end
def stats
JSON.parse(response.body)['body']['stats']
end
private
def chrome!
@request["Accept-Language"] = "en-GB,en-US;q=0.9,en;q=0.8"
@request["Authorization"] = ...
@request["Accept"] = "*/*"
@request["User-Agent"] = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36"
@request["Referer"] = "https://public-api.wordpress.com/wp-admin/rest-proxy/?v=2.0"
@request["Authority"] = "public-api.wordpress.com"
@request["Cookie"] = ...
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment