listings /
import re
from urllib.request import urlopen
from xmlrpc.client import ServerProxy, Error
from xml.parsers.expat import ExpatError
def ping(source_url, target_url):
    Makes a pingback request to target_url on behalf of source_url, i.e.
    effectively saying to target_url that "the page at source_url is
    linking to you".
    def search_link(f):
        content = * 1024)
        match ='<link rel="pingback" href="([^"]+)" ?/?>', content)
        return match and'utf-8')
    request_url = 'http:%s' % target_url if target_url.startswith('//') else target_url
    f = urlopen(request_url)
        info =
        server_url = info.get('X-Pingback', '') or search_link(f)
        if server_url:
            server = ServerProxy(server_url)
  , target_url)
def ping_urls(source_url, target_url_list):
    Makes pingback requests to all links in url list.
    source_url is a URL of the page contaning HTML fragment.
    for url in target_url_list:
            ping(source_url, url)
        except (IOError, Error, ExpatError):
            # One failed URL shouldn't block others