def __init__(self, url="<STR_LIT>", method="<STR_LIT>"):
<EOL>is_post_urlparser = False<EOL>if isinstance(url, URLParser) and url.method == "<STR_LIT>":<EOL><INDENT>is_post_urlparser = True<EOL>url.method = "<STR_LIT>"<EOL><DEDENT>urlstr = str(url)<EOL>if is_post_urlparser: url.method = "<STR_LIT>"<EOL>url = urlstr<EOL>url = urllib.parse.urlsplit(url)<EOL>self.protocol = url[<NUM_LIT:0>]<EOL>self.domain = url[<NUM_LIT:1>]<EOL>self.username = "<STR_LIT>"<EOL>self.password = "<STR_LIT>"<EOL>if self.domain.find("<STR_LIT:@>") >= <NUM_LIT:0>:<EOL><INDENT>login = self.domain.split("<STR_LIT:@>")[<NUM_LIT:0>]<EOL>if login.find("<STR_LIT::>") >= <NUM_LIT:0>:<EOL><INDENT>self.username = login.split("<STR_LIT::>")[<NUM_LIT:0>]<EOL>self.password = login.split("<STR_LIT::>")[<NUM_LIT:1>]<EOL><DEDENT>self.domain = self.domain.split("<STR_LIT:@>")[<NUM_LIT:1>]<EOL><DEDENT>self.port = "<STR_LIT>"<EOL>if self.domain.find("<STR_LIT::>") >= <NUM_LIT:0>:<EOL><INDENT>p = self.domain.split("<STR_LIT::>")<EOL>if p[<NUM_LIT:1>].isdigit():<EOL><INDENT>self.port = p[<NUM_LIT:1>]<EOL>self.domain = p[<NUM_LIT:0>]<EOL><DEDENT><DEDENT>self.path = url[<NUM_LIT:2>]<EOL>self.page = "<STR_LIT>"<EOL>if not self.path.endswith("<STR_LIT:/>"):<EOL><INDENT>if self.path.find("<STR_LIT:/>") >= <NUM_LIT:0>:<EOL><INDENT>self.page = self.path.split("<STR_LIT:/>")[-<NUM_LIT:1>]<EOL>self.path = self.path[:-len(self.page)]<EOL><DEDENT>else:<EOL><INDENT>self.page = self.path<EOL>self.path = "<STR_LIT>"<EOL><DEDENT><DEDENT>self.filename = self.page<EOL>self.query = {}<EOL>self.method = method<EOL>if url[<NUM_LIT:3>] != "<STR_LIT>":<EOL><INDENT>self.method = "<STR_LIT>"<EOL><DEDENT>if is_post_urlparser:<EOL><INDENT>self.method = "<STR_LIT>"<EOL><DEDENT>for param in url[<NUM_LIT:3>].split("<STR_LIT:&>"):<EOL><INDENT>key, value = "<STR_LIT>", "<STR_LIT>"<EOL>if param.find("<STR_LIT:=>") >= <NUM_LIT:0>:<EOL><INDENT>try: (key, value) = param.split("<STR_LIT:=>")<EOL>except:<EOL><INDENT>key = param<EOL><DEDENT><DEDENT>else:<EOL><INDENT>key = param<EOL><DEDENT>if key != "<STR_LIT>":<EOL><INDENT>self.query[key] = value<EOL><DEDENT><DEDENT>self.anchor = url[<NUM_LIT:4>]<EOL>
Splits an url string into different parts.

        The parts are:
        protocol, domain, login, username, password, port, path, page, query, anchor.

        The method defaults to get when the url has a query part.
        Setting it to post will submit the query by POST
        when opening the url.