def _extract_links(self):
extracted = dict()<EOL>try:<EOL><INDENT>for key, value in self.request.links.items():<EOL><INDENT>parsed = urlparse(value["<STR_LIT:url>"])<EOL>fragment = "<STR_LIT>".format(path=parsed[<NUM_LIT:2>], query=parsed[<NUM_LIT:4>])<EOL>extracted[key] = fragment<EOL><DEDENT>parsed = list(urlparse(self.self_link))<EOL>stripped = "<STR_LIT:&>".join(<EOL>[<EOL>"<STR_LIT>" % (p[<NUM_LIT:0>], p[<NUM_LIT:1>])<EOL>for p in parse_qsl(parsed[<NUM_LIT:4>])<EOL>if p[<NUM_LIT:0>] != "<STR_LIT>"<EOL>]<EOL>)<EOL>extracted["<STR_LIT>"] = urlunparse(<EOL>[parsed[<NUM_LIT:0>], parsed[<NUM_LIT:1>], parsed[<NUM_LIT:2>], parsed[<NUM_LIT:3>], stripped, parsed[<NUM_LIT:5>]]<EOL>)<EOL>return extracted<EOL><DEDENT>except KeyError:<EOL><INDENT>return None<EOL><DEDENT>
Extract self, first, next, last links from a request response