Exemple #1
0
def init_headers():
    cookies = 'Hm_lvt_04660099568f561a75456483228a9516=1522044920,1522285410; ASP.NET_SessionId=albbasnvcb4sary4ey33igjb; Hm_lpvt_04660099568f561a75456483228a9516=1522286057'
    jar = requests.cookies.RequestsCookieJar()
    for cookie in cookies.split(';'):
        key, value = cookie.split('=', 1)
        jar.set(key, value)

    headers = {
        'user-agent':
        'Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/65.0.3325.181 Safari/537.36',
        'accept-encoding': 'gzip, deflate, br',
        'accept-language': 'zh-CN,zh;q=0.9,en;q=0.8'
    }
    return (headers, jar)
Exemple #2
0
def enterZhiHu2():
    cookies = '_zap=8d53437e-a20a-4c3c-88ab-626b98f04606; _xsrf=3bc194d5-77cc-4c01-a18a-2f344c94f4c2; d_c0="ACAhicCP9Q-PTujVUruZJV3LIU3u0O5Gdio=|1566957393"; tgw_l7_route=66cb16bc7f45da64562a077714739c11; capsion_ticket="2|1:0|10:1566980643|14:capsion_ticket|44:YmRhZjdkYWNkYWRiNGQxZGI1MzMxYzMxOWQ2MjM3YTI=|cc33f2fcdea8dbee194fa14835a11e286d04c71f7a7552e6fe3d6f8d51985dac"; z_c0="2|1:0|10:1566980663|4:z_c0|92:Mi4xMEJXZkF3QUFBQUFBSUNHSndJXzFEeVlBQUFCZ0FsVk5ONGhUWGdDLVNuY19lX0NsanlubmZFZGRCUVRzbmR0ZC13|407f90e98484f52db12ebbd37c6922fa2ac0d483f441a233f5fd52cdc0f2edfb"; unlock_ticket="AHCA4eH8wAomAAAAYAJVTT9BZl2m9MEXVCtd2pBBYzRNSB0d3wEwlw=="; tst=r'
    jar = requests.cookies.RequestsCookieJar()
    headers = {
        'Host':
        'www.zhihu.com',
        'User-Agent':
        'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.100 Safari/537.36'
    }
    for cookie in cookies.split(';'):
        key, value = cookie.split('=', 1)
        jar.set(key, value)
    r = requests.get('https://www.zhihu.com', cookies=jar, headers=headers)
    print(r.text)
Exemple #3
0
def d():
    cookies = '_zap=a0bc39a5-3fcb-4cea-b90f-feb423f99807; d_c0="AFAhEtSYxw6PTrApweLqfYPHjVm5_MGhrJE=|1546692895"; z_c0="2|1:0|10:1546776788|4:z_c0|92:Mi4xY1JUdUJnQUFBQUFBVUNFUzFKakhEaVlBQUFCZ0FsVk4xRDRmWFFCR2FIcnYtMXpjRktkVnVVV1dxejJqQVI4c0F3|cf2258082c10e93a1f31991deb020e96f623d40aad6287dc1d9b2fc85803fcda"; tst=r; _xsrf=1YNlJuRpxd9xvXD9c25KNskTUzbSsnxW; q_c1=491ee5da8ac3432ba712e1cb658cf42b|1549865260000|1546692897000; __utma=51854390.530225059.1551234814.1551234814.1551234814.1; __utmb=51854390.0.10.1551234814; __utmc=51854390; __utmz=51854390.1551234814.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); __utmv=51854390.100--|2=registration_date=20171217=1^3=entry_date=20171217=1; tgw_l7_route=060f637cd101836814f6c53316f73463'
    jar = requests.cookies.RequestsCookieJar()
    headers = {
        'Host':
        'www.zhihu.com',
        'User-Agent':
        'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.119 Safari/537.36',
    }
    for cookie in cookies.split(';'):
        key, val = cookie.split('=', 1)
        jar.set(key, val)

    r = requests.get('http://www.zhihu.com', cookies=jar, headers=headers)
    print(r.text)
Exemple #4
0
    def check_auth_cookie(self):

        if hasattr(self, 'cookies'):
            cookies = self.cookies

            if not re.match('^(\w+=\w+[;\s]*)+$', cookies):
                return False

            cj = requests.utils.add_dict_to_cookiejar(
                self.session.cookies,
                dict([
                    x.strip().split('=') for x in cookies.split(';') if x != ''
                ])),
            for item in cj:
                if not isinstance(item, requests.cookies.RequestsCookieJar):
                    return False

        return True
Exemple #5
0
import requests.cookies

cookies = '_xsrf=uUq8YhWMu4E3n5uBbanTrkAzsMzSjXIJ; _zap=8c258511-1e22-4d30-bea9-61ea106290db; d_c0="AJDow_Y2aA6PTnwAnL8yeeI7j8LvgWLyyt0=|1540291898"; tst=r; q_c1=12eb8ca00f98451898542474ce016dd6|1540947576000|1540947576000; l_cap_id="NmEzYTg4MzI3ZTZiNDE4ZThjNWRhYjJmZDQyODc1ZjQ=|1541939430|2412ce97a185b02df795a5b26d7a1678300290a1"; r_cap_id="Y2E4YzNkMzc4ODcxNGRmM2E3NDk2Nzc2ODNlYzZjN2U=|1541939430|847101ae6e1c4460ad3e67eb891e9d5e6a73d923"; cap_id="NDY1Zjk0MTg5ZmMzNDYwMzk5NTY4Yzg3NDcyZDIwNTQ=|1541939430|680e6fe0ee7efe92f70f02c397fc574af959fdae"; tgw_l7_route=69f52e0ac392bb43ffb22fc18a173ee6; capsion_ticket="2|1:0|10:1542098409|14:capsion_ticket|44:ZmNjMDA1NjJkNjdhNDA5ZWEyZjdlYTE3NzQ5NGRhOWU=|b4ef6a08c5929f72abad1aa4ae2da55b821ca6c89288d5d0027fdc0360ad76da"; z_c0="2|1:0|10:1542098410|4:z_c0|92:Mi4xY3hOVEJBQUFBQUFBa09qRDlqWm9EaVlBQUFCZ0FsVk42dHZYWEFDalh5aUxKaU5mSjZYUG9EdjVQQ0dPcVJhUlp3|9dad60db3a633e214b3ee4d4c52416465a8d339a5ec14f5caf90a19d9e6646bc"'
jar = requests.cookies.RequestsCookieJar()
headers = {
    'Host':
    'www.zhihu.com',
    'User-Agent':
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.77 Safari/537.36'
}
for cookie in cookies.split(';'):
    key, value = cookie.split('=', 1)
    jar.set(key, value)

r = requests.get('http://www.zhihu.com', cookies=jar, headers=headers)
print(r.text)
Exemple #6
0
    def check_auth_cookie(self):

        if hasattr(self, 'cookies'):
            cookies = self.cookies

            if not re.match('^(\w+=\w+[;\s]*)+$', cookies):
                return False

            cj = requests.utils.add_dict_to_cookiejar(self.session.cookies,
                                                      dict([x.strip().split('=') for x in cookies.split(';')
                                                            if x != ''])),
            for item in cj:
                if not isinstance(item, requests.cookies.RequestsCookieJar):
                    return False

        return True