-

   rss_rss_hh_new

 - e-mail

 

 -

 LiveInternet.ru:
: 17.03.2011
:
:
: 51

:


, 04 2017 . 10:02 +


- , . , . , , . , , , - ...



, , . , - . , . , , , , . , )


- . , , , , , .


.


, . , , , . , , .


.


Habrahabr


: , , .
, , , cookie .


Charles Mac. . , . , , , .


.

, , , . . , . , , . , - .



, :


params = {
    :id => '',
    :post_type => 'simple',
    :flow => 5,
    :hubs => [20742],
    :title => 'test1',
    :text => 'test1',
    :tags_string => 'test1'
}

response = HTTParty.post('https://habrahabr.ru/json/topic/?action=save', headers: headers, body: params)
#  id    
params[:id] = JSON.parse(response.body)['redirect'].split('/')[2]

Flow 5 Hubs 20742 , '' ' ', .


, Habr - :


{
    "system_errors": [
        "  "
    ]
}

. , post_type . . .


, Referer, API . . : draft, :

0 .


, .


, , . :


vote_headers = {
    'Cookie' => HTTP::Cookie.cookie_value(vote_jar.cookies(habr_uri)),
    'User-Agent' => 'Mozilla/5.0',
    'Referer' => 'https://habrahabr.ru/top/',
    'Content-Type' => 'application/x-www-form-urlencoded',
    'Accept' => 'application/json'
}

vote_body = {
#   ? 
    'ti' => params[:id],
    'tt' => 2,
    'v' => 1
}

uri = URI.parse('https://habrahabr.ru/json/vote/')
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
request = Net::HTTP::Post.new(uri.path, vote_headers)
request.body = URI.encode_www_form(vote_body)

#   
puts http.request(request).body

HTTParty , net/http. , , API, : id . .



. Cookies, , , , .


, , . , . .
, . , - . .


, . - delay, :


{
    "system_errors": [
        "   !"
    ]
}

, ' ', . , : ' - !'. .
, , .


, , 30 . .


, 30 , :


122 , . - . :



, , , , .



.


, , . - .


.


P.S. , . sp1nfox, .

Original source: habrahabr.ru (comments, light).

https://habrahabr.ru/post/332296/

:  

: [1] []
 

:
: 

: ( )

:

  URL