Class: ImeiScrapper::Scrapper
- Inherits:
-
Object
- Object
- ImeiScrapper::Scrapper
- Defined in:
- lib/imei-scrapper/scrapper.rb
Constant Summary collapse
- SCRAP_URL =
'https://selfsolve.apple.com/wcResults.do'
- NUMBER_PARAM =
apperantly can be anything, but is required
'blah-blah'
Instance Attribute Summary collapse
-
#imei ⇒ Object
Returns the value of attribute imei.
Instance Method Summary collapse
- #get_info ⇒ Object
-
#initialize(imei) ⇒ Scrapper
constructor
A new instance of Scrapper.
- #request ⇒ Object
Constructor Details
#initialize(imei) ⇒ Scrapper
Returns a new instance of Scrapper.
10 11 12 |
# File 'lib/imei-scrapper/scrapper.rb', line 10 def initialize(imei) @imei = imei end |
Instance Attribute Details
#imei ⇒ Object
Returns the value of attribute imei.
8 9 10 |
# File 'lib/imei-scrapper/scrapper.rb', line 8 def imei @imei end |
Instance Method Details
#get_info ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/imei-scrapper/scrapper.rb', line 14 def get_info begin ImeiScrapper::JSParser.parse_hw_data(request.body) rescue ParseException return nil end end |
#request ⇒ Object
22 23 24 25 26 27 28 29 |
# File 'lib/imei-scrapper/scrapper.rb', line 22 def request uri = URI(SCRAP_URL) req = Net::HTTP::Post.new(uri) req.set_form_data('sn' => @imei, 'num' => NUMBER_PARAM) res = Net::HTTP.start(uri.hostname, uri.port, use_ssl: true) do |http| http.request(req) end end |