def link_to_url(link):
    """
    >>> from scrapy.link import Link
    >>> link_to_url(Link("http://example.com/?foo=bar"))
    'http://example.com/?foo=bar'
    >>> link_to_url(Link("http://example.com/?foo=bar", fragment="id1"))
    'http://example.com/?foo=bar#id1'
    >>> link_to_url(Link("http://example.com/?foo=bar", fragment="!start"))
    'http://example.com/?foo=bar#!start'
    """
    if link.fragment and link.fragment != '#':
        return "#".join([link.url, link.fragment])
    return link.url