def METHOD_NAME(query_data_url):
    """Retrieve and return selected content from mailarch."""
    res = []
    # This has not been rewritten to use requests.get() because get() does
    # not handle file URLs out of the box, which we need for tesing
    with contextlib.closing(urlopen(query_data_url, timeout=15)) as fileobj:
        content_type = fileobj.info()["Content-type"]
        if not content_type.startswith("application/x-tar"):
            if content_type.startswith("text/html"):
                r = fileobj.read(20000)
                q = PyQuery(r)
                div = q('div[class~="no-results"]')
                if div:
                    raise KeyError("No results: %s -> %s" % (query_data_url, div.text(), ))
            raise Exception("Export failed - this usually means no matches were found")
        with tarfile.open(fileobj=fileobj, mode='r|*') as tar:
            for entry in tar:
                if entry.isfile():
                    mbox_fileobj = tar.extractfile(entry)
                    res.extend(retrieve_messages_from_mbox(mbox_fileobj))
    return res