携程酒店数据爬取进阶:动态接口破解与反反爬策略实战

携程酒店数据爬取实战:绕过反爬机制的最新策略 本文针对携程酒店数据爬取中常见的反爬机制,提供了最新的实战策略。核心在于通过模拟登录或从页面请求中动态获取并维护有效的Cookie,并精细化模拟浏览器请求头与行为,从而稳定绕过反爬系统。文章结合完整代码示例,详细阐述了动态Cookie管理、请求头优化及行为模拟等关键技巧,帮助开发者构建更健壮的爬虫。 阅读详情

1. 动态接口参数破解实战

携程酒店数据的动态加载机制一直是爬虫开发者需要攻克的重点难题。最近在做一个酒店比价项目时,我发现携程的接口参数加密又升级了,特别是那个神秘的eleven参数。经过一周的逆向分析,终于摸清了它的生成逻辑,这里分享下我的破解过程。

首先用Chrome开发者工具分析网络请求,发现酒店详情页的价格数据是通过Ajax请求获取的,关键接口是AjaxHote1RoomListForDetai1.aspx。这个接口需要携带多个参数,其中最难搞的就是eleven参数。通过调用栈分析,发现它是由一个经过混淆的JS文件生成的。

1.1 逆向分析JS加密逻辑

在Sources面板找到oceanball相关的JS文件,格式化代码后发现核心逻辑被封装在eval函数中。这里有个小技巧:在Snippets工具里把eval替换为console.log,就能直接看到执行结果。经过多次调试,发现eleven参数实际上是结合了以下要素生成的:

  • 当前时间戳
  • 酒店ID的特定算法
  • 页面加载时的随机种子
  • 用户操作行为指纹

具体实现代码我简化后是这样的:

def generate_eleven(hotel_id):
    timestamp = int(time.time() * 1000)
    seed = (hotel_id * 149) % 233
    dynamic_part = (timestamp + seed) ^ 0xABCDEF
    return f"{dynamic_part}@{hotel_id % 1000}"

1.2 动态Cookie维护策略

除了eleven参数,携程还会校验Cookie中的关键字段。通过实验发现,以下Cookie字段必须有效:

  • _zcy_log_cid
  • MKT_CKID
Python爬虫实战:爬取携程旅游平台数据,我拆解了动态反爬+Cookie续命(附完整可运行代码) 反爬类型表现形式应对思路sign参数返回403/空数据逆向JS还原加密逻辑Cookie时效登录后1小时Cookie失效定时刷新Cookie/保存登录态行为检测爬取过快触发验证码模拟真人延时/随机点击IP封禁单IP爬取超50条数据被封付费代理池/降低请求频率爬取携程旅游平台数据的核心,不是“简单的HTTP请求”,而是“理解平台的反爬逻辑并合规适配”——从sign参数破解到Cookie维护,再到行为模拟,每一步都是对HTTP协议、前端加密、用户行为的深度理解。 阅读详情

相关推荐

Python爬虫:使用Selenium爬取携程民宿列表

爬取携程民宿列表的数据不仅可以帮助研究旅游市场,还可以进行趋势分析、价格预测等。本文将通过使用 Python 和 Selenium 爬取携程民宿列表,教你如何模拟浏览器行为,获取实时数据,并处理反爬虫机制。本文详细介绍了如何使用 Python 和 Selenium 爬取携程民宿列表数据,涵盖了如何打开网页、提取民宿信息、翻页爬取数据以及如何绕过反爬虫机制。携程民宿是其中的一项重要业务,用户可以通过携程预订到各类风格、价位的民宿,成为许多人出行时的首选。爬取的数据可以存储到多种格式中,如 CSV、数据库等。

2201_76125261的博客 1082

Docker启动安装nacos(详情讲解,全网最细)

docker安装nacos保姆级教程

ilvjiale的博客 8万+

全网最全 | Linux(Ubuntn)系统安装 | 硬盘挂载 | 用户创建 | 生信分析配置

昨天(2024年7月23日)我们分享了学生及科研人员电脑配置推荐 | 笔记本+外置显卡配置,性能足够支持完成你博士论文文本内容,那么今天我们就分享一文解决 | Linux(Ubuntn)系统安装 | 硬盘挂载 | 用户创建 | 生信分析配置的教程,我们使用一文来解决大家在做生信时遇到安装系统、配置环境的问题。在此文中,我们尽快可能给出一套全网最全的教程。目标是解决新手小白同学查资源的困惑和难题。但是,每个童鞋遇到的问题不一样,此教程也不可能把你遇到的每个问题都归纳在其中。我们也希望,

BioinfoDu 2261

Transformer-Based Attention Networks for Continuous Pixel-Wise Prediction 基于Transformer注意力网络连续像素级与估计

Transformer-Based Attention Networks for Continuous Pixel-Wise Prediction 基于Transformer注意力网络的连续的像素级的

MengYa_Dream的博客 4716

Oracle MCP Server实战:自然语言如何重塑数据库交互体验

本文深入探讨了Oracle MCP Server如何通过自然语言交互技术革新数据库操作体验。作为Oracle数据库的革命性工具,MCP Server集成了先进的Text-to-SQL技术,允许用户使用自然语言直接查询数据库,大幅降低使用门槛。文章详细介绍了从环境搭建、实战案例到企业级部署的全流程,特别强调了中文自然语言处理能力和安全最佳实践,为DBA和开发者提供了从传统SQL到智能交互的转型指南。

u9v0w的博客 284

Dify基础:Dify平台的本地化部署(含windows部署中,常见问题及解决方案)

第一种比较简单,只需要在浏览器中,打入https://dify.ai/就可以。这个指令虽然看起来简单,但实际上涉及到对docker的使用。这个项目既然有github地址,那它一般就是开源的。我们点开这个github地址,便能看到dify的私有化部署方式。我们可以看到,还是上面那个图,有个按钮,是指向该项目的Github地址的。第二步:按照dify的github给出的指令,对dify进行安装。第一步:我们把dify下载到自己的电脑(或者服务器)上。这里,我们只考虑第二种方式,也就是私有化部署。

xiezhipu的博客 1万+

YOLOv8与注意力机制融合:EMA(高效多维注意力)的原理剖析与实战应用

本文介绍了如何在YOLOv8目标检测模型中集成EMA(高效多尺度注意力)机制。主要内容包括:EMA注意力机制的工作原理解析,展示其多尺度特征融合和高效计算特性;详细的环境配置与依赖安装指南;EMA模块的完整代码实现,包含分组处理、空间注意力权重计算和特征融合等关键步骤;以及将EMA集成到YOLOv8网络结构的方法。通过添加EMA模块,可以提升模型对关键特征的关注能力,有效抑制背景干扰,从而增强目标检测性能。本教程提供了从原理到实现的完整解决方案。

m0_64661770的博客 147

从 AccessControl.authorizationCheck 读懂 ABAP CDS 访问控制:默认策略、取舍边界与一线项目实战

摘要: 本文深入解析ABAP CDS视图中@AccessControl.authorizationCheck注解的核心功能与工程实践。该注解通过DCL角色实现行级数据过滤,提供三类能力:控制访问生效条件、约束语义一致性及管理特权访问。文章详述四种注解取值(#CHECK、#NOT_REQUIRED、#NOT_ALLOWED、#PRIVILEGED_ONLY)的适用场景与默认行为,并结合采购订单案例演示DCL与PFCG授权的落地步骤。同时指出访问控制的边界问题(如JOIN场景可能绕过过滤),并给出视图层级决策矩

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 261

【面试系列】数据工程师高频面试题及详细解答

本文针对数据工程师岗位,提供了详尽的面试题库和解答,分为初级、中级和高级三个层次。初级面试题主要涉及基本的数据处理和ETL工具的使用,如SQL查询、数据清洗和基本的数据建模。中级面试题重点考察数据管道设计、数据库优化和大数据平台的应用。高级面试题则深入探讨高级数据处理技术、分布式系统架构和数据湖的实现。通过这些问题和解答,候选人可以全面了解数据工程师岗位所需的技能,帮助其更好地准备面试。常考知识点总结部分则系统归纳了数据工程师岗位的关键技能领域。

在路上的专栏 2375

RU DOS版、EFI版32bit/64bit BIOS常用工具

DOS版、EFI版的RU工具,可用来查看IO、MEM、PCI、SMBIOS等资源。亲测在EFI SHELL下可用。

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

上一篇: Verilator Linting实战:从警告解读到代码优化的完整指南
下一篇: 竞赛编程中的精度陷阱:从NOI真题看浮点输出的11个避坑指南
eee77
博客等级 码龄14年 50粉丝 1781原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符  | 博主筛选后可见
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值