lbc_api 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 00b88cfd2766eb99b20dda5767cd1780c48a9202
4
- data.tar.gz: cd19f08e00541f11a0ce5650cb3fda1b0fbdf70f
3
+ metadata.gz: b7eaa1e720f9c7955716269c143d66662a9332c8
4
+ data.tar.gz: 87cf04147a80ae39cf3585616193e8406d18ba7e
5
5
  SHA512:
6
- metadata.gz: dd845f4b99a013d48b55fec9b5e89cd10062a753c6bdf1a4a1ae9d4e97bad911aeed9fc7e0048c158cd1d0333370723624356b17304cf9c56204cbaf717f2007
7
- data.tar.gz: e94169fbb846d6f56c57d52d938d76f951e3411bb0a95c1c1c27d7698543496f4d07c6d74f8de7e0e95f02cfdea649d88a40471c0504d00eae50612aa2961511
6
+ metadata.gz: b0b1fc0d2faf7469b1a388d21106f4a82d79705ae8dc60e845331058490b02a5f8a4c29de7afc0f1c67747cb6c950684c05ef8de1a8dcda3dc30d24cfdd91190
7
+ data.tar.gz: 3c48a37681d50392d1643f93c7aaddc03de1cbfc05414f89fe151650d0645334790cc96f56ed3319fb2798f237ae471aac981e12ddfd54a68eb57da742a75215
data/lib/lbc_api/agent.rb CHANGED
@@ -4,6 +4,7 @@ module LbcApi
4
4
  Mechanize.new do |agent|
5
5
  agent.user_agent_alias = 'Mac Safari'
6
6
  agent.follow_meta_refresh = true
7
+ agent.keep_alive = false
7
8
  end
8
9
  end
9
10
  end
@@ -2,7 +2,9 @@ module LbcApi
2
2
  class Classified
3
3
  class << self
4
4
  def create(email, password, data, files = nil)
5
- page = Agent.mecha.get('http://www2.leboncoin.fr/ai')
5
+ agent = Agent.mecha
6
+ page = agent.get('http://www2.leboncoin.fr/ai')
7
+ sleep 3
6
8
  data = Sanitize.params(data).merge({'email' => email})
7
9
  if files && files.count
8
10
  files.each_with_index do |img, i|
@@ -10,7 +12,8 @@ module LbcApi
10
12
  f.file_uploads[i].file_name = img
11
13
  f['extra_images'] = 1
12
14
  end.submit
13
- Agent.mecha.get(page.search('.photo.waiting').at('span')['title'])
15
+ agent.get(page.search('.photo.waiting').at('span')['title'])
16
+ sleep 3
14
17
  end
15
18
  end
16
19
  page = page.form_with(name: 'formular') do |f|
@@ -18,18 +21,22 @@ module LbcApi
18
21
  f[k] = v
19
22
  end
20
23
  end.submit
24
+ sleep 3
21
25
  page.form_with(name: 'formular') do |f|
22
26
  f['passwd'] = password
23
27
  f['passwd_ver'] = password
24
28
  end.submit
29
+ sleep 3
30
+ agent.shutdown
25
31
  end
26
32
 
27
33
  def delete(id, password)
28
34
  page = Agent.mecha.get("http://www2.leboncoin.fr/ai?id=#{id}&cmd=delete")
29
35
  page = page.forms[page.forms.count - 2].submit
30
- page.forms.last do |f|
31
- f['password'] = password
36
+ page = page.form_with(action: '/ai/delete/0') do |f|
37
+ f['passwd'] = password
32
38
  end.submit
39
+ !!page.at('h1:contains("Votre annonce sera supprimée")')
33
40
  end
34
41
 
35
42
  def exists?(title)
@@ -1,3 +1,3 @@
1
1
  module LbcApi
2
- VERSION = '0.0.3'
2
+ VERSION = '0.0.4'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: lbc_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thibault Couraud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-11-28 00:00:00.000000000 Z
11
+ date: 2014-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler