Created
June 29, 2015 18:24
-
-
Save sebotic/d372a84f8987e25a29a7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__author__ = 'Sebastian Burgstaller' | |
from PBB_login import WDLogin | |
import requests | |
import json | |
import pprint | |
user = '' | |
pwd = '' | |
# login = WD_Login(user=user, password=pwd) | |
login_obj = WDLogin(user=user, pwd=pwd, server='test.wikidata.org') | |
cookies = login_obj.get_edit_cookie() | |
edit_token = login_obj.get_edit_token() | |
try: | |
query = 'https://test.wikidata.org/w/api.php' | |
token = edit_token | |
print(token) | |
data = '{"claims":[{"id": "Q1232$CE803569-5434-4D0B-8A80-E0F04C345FB9","remove": ""}]}' | |
headers = {'content-type': 'application/x-www-form-urlencoded'} | |
payload = {'action': 'wbeditentity', | |
'id': 'Q1232', | |
'data': data, | |
'format': 'json', | |
'token': token} | |
print(query) | |
# reply = json.load(urllib2.urlopen(query)) | |
reply = requests.post(query, headers=headers, data=payload, cookies=cookies) | |
json_data = json.loads(reply.text) | |
pprint.pprint(json_data) | |
except requests.HTTPError as e: | |
print(e) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment