1
0
mirror of https://github.com/balkian/jfernando.es.git synced 2025-07-15 19:32:21 +00:00
jfernando.es/extract.py
J. Fernando Sánchez 8edc177252 First commit
2015-10-26 04:03:13 +01:00

27 lines
799 B
Python

import requests
import codecs
print("#"*5 + " XML")
resp = requests.post('https://europass.cedefop.europa.eu/rest/v1/document/extraction',
headers={ "Content-Type": "application/pdf"},
data= open("cv.pdf", "rb")
)
print resp
print resp.text
with codecs.open("cv.xml", "w", encoding="utf-8") as f:
f.write(resp.text)
print("### File written")
print("#"*5 + " JSON")
resp = requests.post('https://europass.cedefop.europa.eu/rest/v1/document/to/json',
headers={ "Content-Type": "application/xml"},
data= open("cv.xml", "rb")
)
print resp
print resp.text
with codecs.open("cv.json", "w", encoding="utf-8") as f:
f.write(resp.text)
print("### File written")