-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdemo.py
executable file
·36 lines (29 loc) · 1.22 KB
/
demo.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
from webmentiontools.urlinfo import UrlInfo
from webmentiontools.webmentionio import WebmentionIO
# If you have an access token from webmention.io,
# set it here. Some calls require it.
webmention_io_token = None
wio = WebmentionIO(webmention_io_token)
# Get all links "mentioning" http://indiewebcamp.com/webmention
target_url = 'http://indiewebcamp.com/webmention'
ret = wio.linksToURL(target_url)
if not ret:
print(wio.error)
else:
for link in ret['links']:
print('')
print('Webmention.io ID: %s' % link['id'])
print(' Source: %s' % link['source'])
print(' Verification Date: %s' % link['verified_date'])
# Now use UrlInfo to get some more information about the source.
# Most web apps showing webmentions, will probably do something
# like this.
info = UrlInfo(link['source'])
print(' Source URL info:')
print(' Title: %s' % info.title())
print(' Pub Date: %s' % info.pubDate())
print(' in-reply-to: %s' % info.inReplyTo())
print(' Author image: %s' % info.image())
print(' Snippet: %s' % info.snippetWithLink(target_url))