--- title: Title keywords: fastai sidebar: home_sidebar nb_path: "examples/create_examples.ipynb" ---
{% raw %}
{% endraw %} {% raw %}

    from fastcore.utils import *
    from fastcore.foundation import *

    from bs4 import BeautifulSoup

{% endraw %} {% raw %}

    hooks_url = 'https://docs.github.com/en/free-pro-team@latest/developers/webhooks-and-events/webhook-events-and-payloads'
    soup = BeautifulSoup(urlread(hooks_url))
    events = L(soup.select('li.ml-0')).attrgot('text')[1:]
    # As at 2020/01/12 the 'sponsor' event has two examples
    sponsor_evt = events.argwhere(lambda o: o.startswith('sponsor'))[0]
    elems = L(soup.select('div.height-constrained-code-block > pre:nth-child(1) > code:nth-child(1)')).attrgot('text')
    # Delete the 2nd sponsor example
    del(elems[sponsor_evt+1])

{% endraw %} {% raw %}

    exs = Path('.')
    for ev,el in zip(events,elems): (exs/f'{ev}.json').write_text(el)

{% endraw %}