当前位置:   article > 正文

cookie与session 在爬虫中的作用_vkmp18.top

vkmp18.top
cookie: 通过在客户端记录信息确定用户的身份
cookie的作用
	反爬
	模拟登陆
  • 1
  • 2
  • 3
  • 4

cookie.py

# @ Time : 2021/2/22 13:58
# @ Author : Ellen


import requests


# url = 'https://www.zhihu.com/'
# url = 'https://www.zhihu.com/hot'
#
# headers = {
#             'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36', 'cookie': '_zap=e3c3fd42-0b69-43bc-a94b-4088a966817c; _xsrf=1f6ndOrrrYy5KIHeMNdI6NZG9LXiYSHn; d_c0="AeBaJoHMsBKPTsYTL2RHaqKbH219bbtmGRo=|1613882415"; Hm_lvt_98beee57fd2ef70ccdd5ca52b9740c49=1613882415; captcha_session_v2="2|1:0|10:1613882436|18:captcha_session_v2|88:REFBMjBHa1I4VnZRTFNlcGlodUxZR1lNS1BVelFEd0VYSDBWZ1VQRHF4S3RKZUtiM1dQSXRsdjBTNWtaM21Ebg==|a88334f88e873aa847f451587a1ac817e0064de614f423bdf16db621ea5a0a30"; captcha_ticket_v2="2|1:0|10:1613882526|17:captcha_ticket_v2|328:eyJhcHBpZCI6IjIwMTIwMzEzMTQiLCJyZXQiOjAsInRpY2tldCI6InQwM0Q1NWtZckxlTFU1bno4dEtWSFdKbkZBUWhiNkwzNUZLQ3NMeVE4VnZkRXVkWG9zOUo1SDhMLUNSRUN1eDVjZDhKTk1CVTI1NWdfczdCT1VXTGozX01XTTRobVpFLW1wT3lpZVh2TGFtbDRaNG4za0daSU8wNFU2RUFCbEFtNkFfeWF4a3d5dG5fQlBZQWx1bmdyeWVtWVp3bk1PeVE0dVFRbk13OTh0QmJYaUhMY1ZGTTNyR1N3KioiLCJyYW5kc3RyIjoiQDZTUiJ9|1fb6ecadbb76478dfac8f17ae748cab1a5b9c864c0defd3dd3405f5b5a392e6e"; z_c0="2|1:0|10:1613882600|4:z_c0|92:Mi4xLWgzS0tnQUFBQUFCNEZvbWdjeXdFaVlBQUFCZ0FsVk42RElmWVFBOXJIbnFhT2hna2RXNVpHRzkyRG5zdXpEYTJn|c428d12daa7142d5df40641fccb54fa26f863b8e279213c4fd9b69453ec2fbbb"; Hm_lpvt_98beee57fd2ef70ccdd5ca52b9740c49=1613973390; SESSIONID=DXgu9qSsi7rBRSUuP1fM3TbpRa5IpujCwryzjN0nOcu; JOID=V14XAkKDVyqcsUPibIfosFzJdMh6xAtO4YQxtRzmY1zd6xy0HQsXEvi-ROVnpHi3lTPkCQMSLX7uUhf-4GSDevE=; osd=WlwWCkKOVSuUsU7gbY_ovV7IfMh3xgpG4YkztBTmbl7c4xy5HwofEvW8Re1nqXq2nTPpCwIaLXPsUx_-7WaCcvE=; tst=h; KLBRSID=d1f07ca9b929274b65d830a00cbd719a|1613973395|1613972203; tshl='
#         }
# res = requests.get(url, headers=headers)
# print(res.text)

# cookie 反爬

def query():
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36',
        'cookie': '_uab_collina=161397416098444804037315; JSESSIONID=4AE304A76954806860F996F40C4D367F; BIGipServerotn=1055916554.50210.0000; RAIL_EXPIRATION=1614315369193; RAIL_DEVICEID=CUtJfv5SUTnIbuD2i7lczp5O_Hh-dfXwexTWKt9RqMx3dP9m6_ZSvU4tOczryTIqHcDb3coU5hGKejHWmW_nZq3230KLUySpzlJtZLqfL5jEQbiNU5B-2I6x5EcI8OobvlMeyWi0IC5tWOErULKo1gvBkALJFQiG; BIGipServerpool_passport=233046538.50215.0000; route=6f50b51faa11b987e576cdb301e545c4; _jc_save_fromStation=%u957F%u6C99%2CCSQ; _jc_save_toStation=%u6210%u90FD%2CCDW; _jc_save_fromDate=2021-02-23; _jc_save_toDate=2021-02-22; _jc_save_wfdc_flag=dc'
    }

    response = requests.get('https://kyfw.12306.cn/otn/leftTicket/queryZ?leftTicketDTO.train_date=2021-02-23&leftTicketDTO.from_station=CSQ&leftTicketDTO.to_station=CDW&purpose_codes=ADULT', headers=headers)

    print(response.content.decode('utf-8'))

query()

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
session 通过服务器记录信息确定用户的身份
	指的是一个保持会话的操作
  • 1
  • 2

session.py

# @ Time : 2021/2/22 15:21
# @ Author : Ellen

import requests

req = requests.session()
def login():
    # 获取图片
    pic_response = req.get('https://kyfw.12306.cn/passport/captcha/captcha-image?login_site=E&module=login&rand=sjrand')
    codeImage = pic_response.content
    fn = open('code2.png', 'wb')
    fn.write(codeImage)
    fn.close()

    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 Safari/537.36'
    }
    codeStr = input('请输入验证码坐标:')

    data = {
       'answer': codeStr,
       'rand': 'sjrand',
        'login_site': 'E'
    }

    response = req.post('https://kyfw.12306.cn/passport/captcha/captcha-check', data=data, headers=headers)

    print(response.text)

login()
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30

text.py

# @ Time : 2021/2/22 15:21
# @ Author : Ellen

import base64

img_url = '/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIy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/pUU39v8Rtnb9j69P9v2r1aij2FPsHMzyC6+BguOniLYcY/48c/+1K9Yu7YXUQQttw2c4zU9FXGEY/CDdzLOjKRgy/8Ajv8A9es288FWN/kXBWRT2aPI/nXTUVYXOGPwq8OE5axtG/3rcH+tWIPhtoFs4eHT7CNx0ZbRQfzrsaKBqcl1MFfDEKqFWVVA9I//AK9KPDaA5+0DP/XP/wCvW7RQHMzIj0IRn/j4z/wD/wCvUn9kf9Nv/HP/AK9adFBL1CiiigAAgAEAUQkBiAERhgEhYhEosAD/2QoK'

img_data = base64.b64decode(img_url)
fn = open('code.png', 'wb')
fn.write(img_data)
fn.close()

'''
https://kyfw.12306.cn/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand&1613984250091&callback=jQuery1910931937780684972_1613984238850&_=1613984238851

https://kyfw.12306.cn/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand&1613984433978&callback=jQuery191014746224530283292_1613984412513&_=1613984412515

找到两次相同的url 再删除64,就可以获取到图片--->指向12306验证码图片
https://kyfw.12306.cn/passport/captcha/captcha-image64?login_site=E&module=login&rand=sjrand

'''
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/2023面试高手/article/detail/450928
推荐阅读
相关标签
  

闽ICP备14008679号