User:Euna/prototyping 14: Difference between revisions
(Created page with "= Wiki API = ==API== Application Programming Interface. Get info from A (site, app) and export to B possible to get in query and parse query : /api.php?action=query&<b>titl...") |
(No difference)
|
Revision as of 21:31, 21 January 2021
Wiki API
API
Application Programming Interface. Get info from A (site, app) and export to B
possible to get in query and parse
query : /api.php?action=query&titles=Category:Situationist_Times&format=json
parse : /api.php?action=query&page=Category:Situationist_Times&format=json
Read and Write with API
to read a content;
import urllib
import json
request = urllib.request.urlopen(url).read()
data = json.loads(request)
data
to write a content;
test = "hello"
out = open('test.html', 'w')
out.write(test)
out.close()
#or for writing an exported html content
data = html
out = open('test.html', 'w')
out.write(html)
out.close()
In json form, possible to choose a specific result with []
# data result : {'parse': {'title': ......
data = html[parse][title] #gives only the title value