python爬虫小技巧

headers转换为字典格式

把headers放入sublime,ctrl+H打开替换功能,打开正则选项

(.*?):\s(.*)
"$1":"$2"

在这里插入图片描述
点击replace all替换所有,结果:

"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:94.0) Gecko/20100101 Firefox/94.0",
"Accept":"*/*",
"Accept-Language":"zh-CN",
"Accept-Encoding":"gzip, deflate",
"Referer":"https://www.bilibili.com/video/BV1r541137ir?p=23",
"Origin":"https://www.bilibili.com",
"Connection":"close",
"Cookie":"buvid3=F2FD4EB0-15DC-41AB-8D34-D843F00C2E4807558infoc; CURRENT_FNVAL=976; _uuid=A057F25B-8F31-3EDA-F032-24DE5209F36808397infoc; blackside_state=1; rpdid=|(YuR|RmlYl0J'uYkJY~Yluu; PVID=1; fingerprint=d083a381d5859b0a96ee67d465189ab5; DedeUserID=19292218; DedeUserID__ckMd5=628fa9c944a06384; SESSDATA=17eea508%2C1640783317%2C471fb*71; bili_jct=701f3c04490a2794be833fe3894f4f1e; CURRENT_QUALITY=80; bp_video_offset_19292218=587700857813132776; LIVE_BUVID=AUTO1916353000178526; bp_t_offset_19292218=587700857813132776; video_page_version=v_old_home; innersign=1; sid=90acql14; deviceFingerprint=48eb47eac040ae44666fb5a861afefea; bsource=search_baidu; b_lsid=C3A1E6A9_17D5B04C099",
"Sec-Fetch-Dest":"empty",
"Sec-Fetch-Mode":"cors",
"Sec-Fetch-Site":"same-site",

post参数转换为字典

&
\n

在这里插入图片描述

(.*?)=(.*)
"$1":"$2",

在这里插入图片描述
结果:

"aid":"460532117",
"cid":"336611258",
"bvid":"BV1r541137ir",
"mid":"19292218",
"csrf":"701f3c04490a2794be833fe3894f4f1e",
"played_time":"579",
"real_played_time":"641",
"realtime":"29",
"start_ts":"1637910375",
"type":"3",
"dt":"2",
"play_type":"2",
"from_spmid":"333.788.segment_within_video.0",
"spmid":"333.788.0.0",
"auto_continued_play":"1",
"refer_url":"https%3A%2F%2Fsearch.bilibili.com%2Fall%3Fkeyword%3Dapp%25E9%2580%2586%25E5%2590%2591%26from_source%3Dwebtop_search%26spm_id_from%3D333.851",
"bsource":"search_baidu",
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值