Skip to content

Instantly share code, notes, and snippets.

@apeyroux
Created November 14, 2022 21:58
Show Gist options
  • Save apeyroux/060971a9213e3a0f8795bbb534b28efe to your computer and use it in GitHub Desktop.
Save apeyroux/060971a9213e3a0f8795bbb534b28efe to your computer and use it in GitHub Desktop.
import json
import requests
from bs4 import BeautifulSoup
import sys
with open('voc.json') as f:
voc = json.load(f)
for m in voc['fr']['3']['favoris']:
mot = m['favori']['graphie'].capitalize()
definition_html = m['apercu']
definition = BeautifulSoup(definition_html, 'html.parser').text
resp = requests.post(
url="https://readwise.io/api/v2/highlights/",
headers={"Authorization": "Token xxxxx"},
json={
"highlights": [{
"text": definition,
"title": mot,
"note": ".vocabulaire",
"author": "Antidote",
"source_type": "antidote2readwise",
"category": "articles"
}]
}
)
if resp.status_code != 200:
print(resp.status_code)
print(resp.text)
else:
print("Added {} ...".format(mot))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment