tweakphoeus 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +1 -0
- data/README.md +9 -2
- data/lib/tweakphoeus/version.rb +1 -1
- data/lib/tweakphoeus.rb +6 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 25fcb7384bff257ed82f16287a2078fb1ab6df54
|
4
|
+
data.tar.gz: b6cf182064ac2b990da3eb9cb3b6349cb09133c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f9a15688c4bf67db44d22aa55c0ca36921763ea6e4ed1a7f4a7e30c2795c7468e6a2162b20a1c71dbfaa36e4c9b306a23aa19d00cd347b6c94eb0100c2d0f5fa
|
7
|
+
data.tar.gz: 3e291860a978a89b0835cf391e3c3dd4b1dfe4c1c2f5bad27a98895e76a7d18ce1a5621e0fb7d006824c7a854d57cd13c6b4eb4be7807586c026d696c37acbb7
|
data/CHANGELOG.md
CHANGED
data/README.md
CHANGED
@@ -5,9 +5,12 @@
|
|
5
5
|
[![Issue Count](https://codeclimate.com/github/basestylo/Tweakphoeus/badges/issue_count.svg)](https://codeclimate.com/github/basestylo/Tweakphoeus)
|
6
6
|
# Tweakphoeus
|
7
7
|
|
8
|
-
|
8
|
+
We usually describe this gem as 'typhoeus on steroids'. We add some browser features, for example cookies management and automation in tipical headers that browsers define in his HTTP stack.
|
9
|
+
|
10
|
+
We love scrapping and this gem was created for this.
|
11
|
+
|
12
|
+
From crazy developers to another crazy developers, Created in Bizneo.com and maintained in this small group of developers.
|
9
13
|
|
10
|
-
TODO: Delete this and the text above, and describe your gem
|
11
14
|
|
12
15
|
## Installation
|
13
16
|
|
@@ -26,6 +29,10 @@ Or install it yourself as:
|
|
26
29
|
$ gem install tweakphoeus
|
27
30
|
|
28
31
|
## Usage
|
32
|
+
Like Typhoeus
|
33
|
+
|
34
|
+
Tweakphoeus.get(url)
|
35
|
+
Tweakphoeus.get(url, headers: hash, body: hash)
|
29
36
|
|
30
37
|
TODO: Write usage instructions here
|
31
38
|
|
data/lib/tweakphoeus/version.rb
CHANGED
data/lib/tweakphoeus.rb
CHANGED
@@ -4,6 +4,7 @@ require "typhoeus"
|
|
4
4
|
module Tweakphoeus
|
5
5
|
class Client
|
6
6
|
attr_accessor :cookie_jar
|
7
|
+
attr_accessor :base_headers
|
7
8
|
|
8
9
|
def initialize()
|
9
10
|
@cookie_jar = {}
|
@@ -12,7 +13,6 @@ module Tweakphoeus
|
|
12
13
|
"User-Agent" => "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:42.0) Gecko/20100101 Firefox/42.0",
|
13
14
|
"Accept-Language" => "es-ES,es;q=0.8,en-US;q=0.5,en;q=0.3",
|
14
15
|
"Accept-Encoding" => "",
|
15
|
-
"DNT" => "1",
|
16
16
|
"Connection" => "keep-alive"
|
17
17
|
}
|
18
18
|
end
|
@@ -57,7 +57,7 @@ module Tweakphoeus
|
|
57
57
|
private
|
58
58
|
|
59
59
|
def http_request(url, body: nil, headers: nil, redirect: false, method: method)
|
60
|
-
request_headers =
|
60
|
+
request_headers = merge_default_headers(headers)
|
61
61
|
request_headers["Cookie"] = inject_cookies(url, headers)
|
62
62
|
request_headers["Referer"] = get_referer
|
63
63
|
response = Typhoeus.send(method, url, body: body, headers: request_headers)
|
@@ -77,6 +77,10 @@ module Tweakphoeus
|
|
77
77
|
response
|
78
78
|
end
|
79
79
|
|
80
|
+
def merge_default_headers headers
|
81
|
+
headers ? @base_headers.merge(headers) : @base_headers
|
82
|
+
end
|
83
|
+
|
80
84
|
def obtain_cookies response
|
81
85
|
set_cookies_field = response.headers["Set-Cookie"]
|
82
86
|
return if set_cookies_field.nil?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tweakphoeus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Martin Garcia
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: typhoeus
|