处理cookie登录小说网爬取小说

import requests
session = requests.session()

#第一种方法

data = {
    "loginName": "13220677880",
    "password": "*********"
}

url = "https://passport.17k.com/ck/user/login"

session.post(url, data=data)

resp = session.get("https://user.17k.com/ck/author/shelf?page=1&appKey=2406394919")

print(resp.json())

#第二种方法
#resp = requests.get("https://user.17k.com/ck/author/shelf?page=1&appKey=2406394919",headers={
#    "Cookie": "GUID=2efe44fe-cc36-4ce0-937f-f82d89a80d4d; BAIDU_SSP_lcr=https://www.baidu.com/link?url=-vUjrKoCn9Cy02pXmbdHBBC2ED8YduLOTlwRWD7ja0O&wd=&eqid=ff7cfa5a0004968b00000003613d9d0d; Hm_lvt_9793f42b498361373512340937deb2a0=1631427866; sajssdk_2015_cross_new_user=1; c_channel=0; c_csc=web; accessToken=avatarUrl%3Dhttps%253A%252F%252Fcdn.static.17k.com%252Fuser%252Favatar%252F03%252F03%252F54%252F79985403.jpg-88x88%253Fv%253D1631427971000%26id%3D79985403%26nickname%3D%25E4%25B8%2580%25E6%25A2%25A6%25E6%25B1%259F%25E6%25B9%25961233%26e%3D1646980519%26s%3D76587a02ce54df53; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2279985403%22%2C%22%24device_id%22%3A%2217bd8adac668b3-0952812f8de68b-335c4c73-1327104-17bd8adac67519%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.baidu.com%2Flink%22%2C%22%24latest_referrer_host%22%3A%22www.baidu.com%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%7D%2C%22first_id%22%3A%222efe44fe-cc36-4ce0-937f-f82d89a80d4d%22%7D; Hm_lpvt_9793f42b498361373512340937deb2a0=1631429724"
#})
#print(resp.text) 直接复制cookie来爬取数据

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

天行九歌。

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值