def get_share_uk_and_shareid(cookie, url):
def parse_share_uk(content):<EOL><INDENT>'''<STR_LIT>'''<EOL>uk_reg = re.compile('<STR_LIT>')<EOL>shareid_reg = re.compile('<STR_LIT>')<EOL>uk_match = uk_reg.search(content)<EOL>shareid_match = shareid_reg.search(content)<EOL>if uk_match and shareid_match:<EOL><INDENT>return False, uk_match.group(<NUM_LIT:1>), shareid_match.group(<NUM_LIT:1>)<EOL><DEDENT>else:<EOL><INDENT>return None<EOL><DEDENT><DEDENT>def parse_uk_from_url(url):<EOL><INDENT>uk_reg = re.compile('<STR_LIT>')<EOL>uk_match = uk_reg.search(url)<EOL>shareid_reg = re.compile('<STR_LIT>')<EOL>shareid_match = shareid_reg.search(url)<EOL>if not uk_match or not shareid_match:<EOL><INDENT>return '<STR_LIT>', '<STR_LIT>'<EOL><DEDENT>uk = uk_match.group(<NUM_LIT:1>)<EOL>shareid = shareid_match.group(<NUM_LIT:1>)<EOL>return uk, shareid<EOL><DEDENT>req = net.urlopen_without_redirect(url, headers={<EOL>'<STR_LIT>': cookie.header_output(),<EOL>})<EOL>if req and req.headers.get('<STR_LIT>'):<EOL><INDENT>init_url = req.headers.get('<STR_LIT>')<EOL>if init_url.find('<STR_LIT>') > -<NUM_LIT:1>:<EOL><INDENT>uk, shareid = parse_uk_from_url(init_url)<EOL>return True, uk, shareid<EOL><DEDENT><DEDENT>if url.startswith('<STR_LIT>'):<EOL><INDENT>req = net.urlopen(url, headers={<EOL>'<STR_LIT>': cookie.header_output(),<EOL>})<EOL>if req:<EOL><INDENT>return parse_share_uk(req.data.decode())<EOL><DEDENT><DEDENT>uk, shareid = parse_uk_from_url(url)<EOL>return False, uk, shareid<EOL>
从共享链接中提示uk和shareid.

    如果共享文件需要输入密码, 就会将need_pwd设为True
    如果成功, 返回(need_pwd, uk, shareid)
    如果失败, 就返回None

    目前支持的链接格式有:
      * http://pan.baidu.com/wap/link?uk=202032639&shareid=420754&third=0
      * http://pan.baidu.com/share/link?uk=202032639&shareid=420754
      * http://pan.baidu.com/s/1i3iQY48