Class: Ubiquitously::Favshare::Post
- Inherits:
-
Service::Post
- Object
- Base
- Service::Post
- Ubiquitously::Favshare::Post
- Defined in:
- lib/ubiquitously/services/favshare.rb
Overview
see your posts here: favshare.net/user/history/viatropos/
Instance Attribute Summary
Attributes inherited from Service::Post
#captcha, #categories, #description, #downvotes, #extension, #format, #image, #kind, #must_be_unique, #privacy, #rating, #remote, #service_id, #service_url, #slug, #source, #source_url, #state, #status, #tags, #title, #token, #upvotes, #url, #user, #vote
Instance Method Summary collapse
- #create ⇒ Object
-
#tokenize ⇒ Object
max tags == 40 chars.
Methods inherited from Service::Post
Methods included from Loggable::Post
Methods included from Restful::Post
Methods included from Postable::Post
Methods included from Ownable::Post
Methods inherited from Base
Methods included from SubclassableCallbacks
Constructor Details
This class inherits a constructor from Ubiquitously::Service::Post
Instance Method Details
#create ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/ubiquitously/services/favshare.rb', line 24 def create page = agent.get("http://favshare.net/submit.php") form = page.forms.detect {|form| form.form_node["id"] == "thisform"} form["url"] = url page = form.submit form = page.forms.detect {|form| form.form_node["id"] == "thisform"} form["title"] = title form["bodytext"] = description # 350 chars max form["summarytext"] = description # MALFORMATTED HTML: select box is outside of the form #form.fields_with(:name => "category").first.options.each do |option| # option.select if option.value.to_s == "3" #end # b/c of malformedness... form["category"] = "3" form["url"] = url form["phase"] = "2" form["randkey"] = page.parser.css("input[@name='randkey']").first["value"] form["id"] = page.parser.css("input[@name='id']").first["value"] form["tags"] = token[:tags] # comma separated with space iframe_url = page.parser.css("noscript iframe").first["src"] params = iframe_url.split("?").last captcha_iframe = agent.click(page.iframes.first) captcha_form = captcha_iframe.forms.first captcha_image = captcha_iframe.parser.css("img").first["src"] # open browser with captcha image system("open", "http://api.recaptcha.net/#{captcha_image}") # enter captcha response in terminal captcha_says = ask("Enter Captcha from Browser Image: ") { |q| q.echo = true } captcha_form["recaptcha_response_field"] = captcha_says # submit captcha captcha_form.action = "http://www.google.com/recaptcha/api/noscript?#{params}" captcha_response = captcha_form.submit # grab secret captcha_response = captcha_response.parser.css("textarea").first.text form["recaptcha_challenge_field"] = captcha_response form["recaptcha_response_field"] = "manual_challenge" page = form.submit unless debug? form = page.forms.detect {|form| form.form_node["id"] == "thisform"} page = form.submit end true end |
#tokenize ⇒ Object
max tags == 40 chars
20 21 22 |
# File 'lib/ubiquitously/services/favshare.rb', line 20 def tokenize super.merge(:tags => .taggify(" ", ", ", 40)) end |