示例#1
0
    rslt = "".join(("data=", rslt))
    return rslt


email_address = sys.argv[1]
passwd = sys.argv[2]

H_string = """Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36
Accept-Encoding: gzip,deflate,sdch
Accept-Language: zh-CH,zh;q=0.8"""
cc_Soli = nave.solicitud()
url = {}
url[1] = "https://www.linkedin.com/"
cc_Scrr = nave.walkon(
    1, url[1], "GET", soli=cc_Soli, default_Port=80, conn=None, H_string=H_string, C_headers_Dict=None, C_body=None
)
cc_Step = cc_Scrr[0]
cc_Conn = cc_Scrr[1]
resp_head = cc_Scrr[2]
resp_body = cc_Scrr[3]
write_to_file(fn=url_to_fn(url[1]), content=resp_body, op="wb+")
html_text = resp_body.decode("utf-8")
signin_link_href = get_signin_link_href(html_text)
req_head = {}
resp_cookie_str = select_valid_cookies_from_resp(req_head, resp_head, url[1], signin_link_href)
req_cookie_str = resp_cookie_str
curr_head_string = "".join((H_string, "\n", req_cookie_str))
req_head = cc_Soli.build_Headers_Dict(curr_head_string, "\n")
req_head["Referer"] = url[1]
url[5] = signin_link_href
示例#2
0
def linkedin_login(email_address,passwd):
    H_string = '''Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
    User-Agent: Mozilla/5.0 (Windows NT 6.3; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.94 Safari/537.36
    Accept-Encoding: gzip,deflate,sdch
    Accept-Language: zh-CH,zh;q=0.8'''
    cc_Soli = nave.solicitud()
    url = {}
    url[1] = "https://www.linkedin.com/"
    cc_Scrr = nave.walkon(1,url[1],'GET',soli=cc_Soli,default_Port=80,conn=None,H_string=H_string,C_headers_Dict=None,C_body=None)
    cc_Step = cc_Scrr[0]
    cc_Conn = cc_Scrr[1]
    resp_head = cc_Scrr[2]
    resp_body = cc_Scrr[3]
    write_to_file(fn=url_to_fn(url[1]),content=resp_body,op='wb+')
    html_text = resp_body.decode('utf-8')
    signin_link_href = get_signin_link_href(html_text)
    req_head = {}
    resp_cookie_str = select_valid_cookies_from_resp (req_head,resp_head,url[1],signin_link_href)
    req_cookie_str = resp_cookie_str
    curr_head_string = ''.join((H_string,'\n',req_cookie_str))
    req_head = cc_Soli.build_Headers_Dict(curr_head_string,'\n')
    req_head['Referer'] = url[1]
    print('stage_1')
    url[5] = signin_link_href
    cc_Scrr = nave.walkon(cc_Step,url[5],'GET',soli=cc_Soli,default_Port=80,conn=cc_Conn,H_string=None,C_headers_Dict=req_head,C_body=None)
    cc_Step = cc_Scrr[0]
    cc_Conn = cc_Scrr[1]
    resp_head = cc_Scrr[2]
    resp_body = cc_Scrr[3]
    from_url = url[1]
    to_url = url[5]
    resp_cookie_str = select_valid_cookies_from_resp (req_head,resp_head,from_url,to_url)
    req_cookie_str = resp_cookie_str
    curr_head_string = ''.join((H_string,'\n',req_cookie_str))
    req_head = cc_Soli.build_Headers_Dict(curr_head_string,'\n')
    req_head['Referer'] = url[5]
    req_head['Content-Type'] = 'application/x-www-form-urlencoded'
    write_to_file(fn='p5.html',content=resp_body,op='wb+')
    html_text = resp_body.decode('utf-8')
    root = etree.HTML(html_text)
    eles = root.xpath('//form[@name="login"]')
    od = collections.OrderedDict(eles[0].items())
    action = od['action']
    method = od['method']
    eles = root.xpath('//form[@name="login"]//input')
    req_body = gen_login_post_body(eles,email_address,passwd)
    print('stage_2')
    url[7] = action
    from_url = url[1]
    to_url = action
    cc_Scrr = nave.walkon(cc_Step,url[7],method,soli=cc_Soli,default_Port=80,conn=cc_Conn,H_string=None,C_headers_Dict=req_head,C_body=req_body)
    cc_Step = cc_Scrr[0]
    cc_Conn = cc_Scrr[1]
    resp_head = cc_Scrr[2]
    resp_body = cc_Scrr[3]
    from_url = url[1]
    to_url = url[7]
    resp_cookie_str = select_valid_cookies_from_resp (req_head,resp_head,from_url,to_url)
    req_cookie_str = resp_cookie_str
    curr_head_string = ''.join((H_string,'\n',req_cookie_str))
    req_head = cc_Soli.build_Headers_Dict(curr_head_string,'\n')
    rslt = {}
    rslt['req_head']=req_head
    rslt['location']=select_headers_via_key(resp_head.getheaders(),'Location')[0][1]
    rslt['conn']=cc_Conn
    rslt['step']=cc_Step
    return(rslt)