最近在做个淘宝搜索遇到的坑吧

1 淘宝的页面没有jquery需要在加载之后用cef注入jquery
OnLoadEnd后
const CefString js = “var v = document.createElement(‘script’);v.src=‘https://libs.baidu.com/jquery/2.0.0/jquery.min.js’;document.body.appendChild(v);”;
frame->ExecuteJavaScript(js, frame->GetURL(), 0);
const CefString js2 = u8"var v = document.createElement(‘script’); v.charset=‘utf-8’;v.innerHTML = "function pagechangeto(npagecount) { var htmlarrt = ‘[aria-label=第’+npagecount+‘页]’;$(htmlarrt)[0].click(); }; “; document.body.appendChild(v);”;
frame->ExecuteJavaScript(js2.ToString(), frame->GetURL(), 0);
2 cef抓取request的reponse的content 我使用的是GetResourceResponseFilter的接口但是这个接口会相应很多次 文档上说的是
// Called to filter a chunk of data. Expected usage is as follows:
调用以筛选数据块。预期用途如下:
//
// A. Read input data from |data_in| and set |data_in_read| to the number of
// bytes that were read up to a maximum of |data_in_size|. |data_in| will
// be NULL if |data_in_size| is zero.
A、 从| data|in|读取输入数据,并将| data_in_read|设置为读取的最大字节数| data_in_size|。如果|data_in_size|为零,|data_in|的数据为空。
// B. Write filtered output data to |data_out| and set |data_out_written| to
// the number of bytes that were written up to a maximum of
// |data_out_size|. If no output data was written then all data must be
// read from |data_in| (user must set |data_in_read| = |data_in_size|).
B、 将过滤后的输出数据写入| data_out |并将| data_out_written |设置为写入的最大字节数为|data_out_size|。如果没有输出数据被写入,则所有数据必须从| data_in|读取(用户必须设置| data_in_read |=| data_in_size|)。
// C. Return RESPONSE_FILTER_DONE if all output data was written or
// RESPONSE_FILTER_NEED_MORE_DATA if output data is still pending.
C、如果所有输出数据都已写入,则返回RESPONSE_FILTER_DONE;如果输出数据仍处于挂起状态,则RESPONSE_FILTER_NEED_MORE_data。
//
// This method will be called repeatedly until the input buffer has been
// fully read (user sets |data_in_read| = |data_in_size|) and there is no
// more input data to filter (the resource response is complete). This method
// may then be called an additional time with an empty input buffer if the
// user filled the output buffer (set |data_out_written| = |data_out_size|)
// and returned RESPONSE_FILTER_NEED_MORE_DATA to indicate that output data is
// still pending.
此方法将被反复调用,直到输入缓冲区被完全读取(用户将| data_in_read |=| data_in_size |)并且没有更多的输入数据要过滤(资源响应完成)。此方法额外使用空的缓冲区调用一次如果用户填充了输出缓冲区(set | data_out_written |=| data_out_size |)并且返回的RESPONSE_FILTER_NEED_MORE_data以指示输出数据仍处于挂起状态
//
// Calls to this method will stop when one of the following conditions is met:
满足以下条件之一时,对此方法的调用将停止:
//
// A. There is no more input data to filter (the resource response is
// complete) and the user sets |data_out_written| = 0 or returns
// RESPONSE_FILTER_DONE to indicate that all data has been written, or;
A、没有更多的输入数据要过滤(资源响应完成),用户设置| data_out_written |=0或返回response_filter_DONE以指示所有数据已写入,或;
// B. The user returns RESPONSE_FILTER_ERROR to indicate an error.
B、 用户返回响应RESPONSE_FILTER_ERROR错误以指示错误。
//
但是经过测试发现当data_in_size = 65536的时候下一帧的数据data_in_size = 0 data_in = null 不知道为啥,这样就无法判断当前的reponse是否结束,但是淘宝这里返回的是json我就只能通过判断json是否合法然后继续做操作了。

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
好的,以下是一个简单的搜索页面的HTML和CSS代码示例: ```HTML <!DOCTYPE html> <html> <head> <title>搜索</title> <style type="text/css"> body { background-color: #f5f5f5; font-family: Arial, sans-serif; } .container { margin: 0 auto; width: 960px; padding: 20px; background-color: #fff; box-shadow: 0 0 10px rgba(0,0,0,0.2); } .header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 20px; } .logo { font-size: 32px; font-weight: bold; color: #ff4400; } .search-box { display: flex; align-items: center; height: 40px; border: 1px solid #ccc; border-radius: 20px; overflow: hidden; } .search-input { flex: 1; height: 100%; padding: 0 20px; border: none; font-size: 18px; } .search-button { height: 100%; padding: 0 20px; background-color: #ff4400; border: none; color: #fff; font-size: 18px; cursor: pointer; } .category-list { display: flex; align-items: center; margin-bottom: 20px; } .category-item { margin-right: 20px; color: #666; font-size: 16px; cursor: pointer; } .category-item.active { color: #ff4400; font-weight: bold; } .product-list { display: flex; flex-wrap: wrap; margin-bottom: 20px; } .product-item { flex: 0 0 25%; padding: 20px; background-color: #fff; box-shadow: 0 0 5px rgba(0,0,0,0.1); margin-right: 20px; margin-bottom: 20px; } .product-item:last-child { margin-right: 0; } .product-item .image { height: 200px; background-color: #f5f5f5; margin-bottom: 10px; } .product-item .title { font-size: 16px; color: #333; margin-bottom: 10px; } .product-item .price { font-size: 18px; color: #ff4400; font-weight: bold; } </style> </head> <body> <div class="container"> <div class="header"> <div class="logo">搜索</div> <div class="search-box"> <input type="text" class="search-input" placeholder="请输入关键字"> <button class="search-button">搜索</button> </div> </div> <div class="category-list"> <div class="category-item active">全部</div> <div class="category-item">女装</div> <div class="category-item">男装</div> <div class="category-item">鞋包</div> <div class="category-item">运动</div> <div class="category-item">数码</div> <div class="category-item">家电</div> <div class="category-item">美妆</div> <div class="category-item">母婴</div> <div class="category-item">家居</div> <div class="category-item">食品</div> </div> <div class="product-list"> <div class="product-item"> <div class="image"></div> <div class="title">商品1</div> <div class="price">¥100.00</div> </div> <div class="product-item"> <div class="image"></div> <div class="title">商品2</div> <div class="price">¥200.00</div> </div> <div class="product-item"> <div class="image"></div> <div class="title">商品3</div> <div class="price">¥300.00</div> </div> <div class="product-item"> <div class="image"></div> <div class="title">商品4</div> <div class="price">¥400.00</div> </div> <div class="product-item"> <div class="image"></div> <div class="title">商品5</div> <div class="price">¥500.00</div> </div> <div class="product-item"> <div class="image"></div> <div class="title">商品6</div> <div class="price">¥600.00</div> </div> <div class="product-item"> <div class="image"></div> <div class="title">商品7</div> <div class="price">¥700.00</div> </div> <div class="product-item"> <div class="image"></div> <div class="title">商品8</div> <div class="price">¥800.00</div> </div> </div> </div> </body> </html> ``` 以上代码实现了一个简单的搜索页面,包括搜索框、分类列表和商品列表等内容。你可以根据需要进行修改和扩展。
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值