Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 54fc8ff3 authored by POUILLOUX Laurent's avatar POUILLOUX Laurent
Browse files

Merge branch 'fix_mw_api_content_retrieve' into 'master'

[gen:wiki] change method to get page text content

See merge request !576
parents e19bd1d5 c31ca088
No related branches found
No related tags found
1 merge request!576[gen:wiki] change method to get page text content
Pipeline #876389 passed
...@@ -6,20 +6,23 @@ module MediawikiApi ...@@ -6,20 +6,23 @@ module MediawikiApi
class Client class Client
def get_page_content(page_name) def get_page_content(page_name)
get_conn = Faraday.new(url: MW::BASE_URL + "index.php/#{page_name}") do |faraday|
get_conn = Faraday.new(url: MW::API_URL) do |faraday|
faraday.request :multipart faraday.request :multipart
faraday.request :url_encoded faraday.request :url_encoded
faraday.use :cookie_jar, jar: @cookies faraday.use :cookie_jar, jar: @cookies
faraday.use FaradayMiddleware::FollowRedirects faraday.use FaradayMiddleware::FollowRedirects
faraday.adapter Faraday.default_adapter faraday.adapter Faraday.default_adapter
end end
params = { params = {
:token_type => false, :action => 'parse',
:action => 'raw' :page => page_name,
:prop => 'wikitext',
:formatversion => '2',
:format => 'json'
} }
params[:token] = get_token(:csrf)
res = get_conn.send(:get, '', params) res = get_conn.send(:get, '', params)
res.body JSON::parse(res.body)["parse"]["wikitext"]
end end
def get_file_content(file_name) def get_file_content(file_name)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment