I looked through the documentation
The URI module provides a fragment attribute. eg:
URI
fragment
>> uri = URI("http://example.com/index.php?q=something#anchor") >> uri.fragment => "anchor"