短视频素材免费下载网站wordpress 使用主题

当前位置: 首页 > news >正文

短视频素材免费下载网站,wordpress 使用主题,wordpress4.5.3zhcn,网站做全景问题 随便拿一篇电影做样例。我们发现猫眼的页面数据在预览窗口中全是小方框。在当我们拿到源码以后#xff0c;数据全是加密后的。所以我们需要想办法破解加密#xff0c;拿到数据。 破解过程 1.源码获取问题与破解 分析 在我们刚刚请求url的时候是可以得到数据的#xff…问题 随便拿一篇电影做样例。我们发现猫眼的页面数据在预览窗口中全是小方框。在当我们拿到源码以后数据全是加密后的。所以我们需要想办法破解加密拿到数据。 破解过程  1.源码获取问题与破解 分析 在我们刚刚请求url的时候是可以得到数据的但是过了一段时间后就无法获得数据。虽然状态码为200但是却没有返回页面源码 一般这种应该是和时间戳有关系在查看请求负载的时候我们发送浏览器向这个url不仅发送了时间戳还有一个signKey的密钥。时间戳可以很容易得到主要问题是如何获得signKey。 全局搜索signKey我们发现一段js代码它的返回值就是我们请求负载的内容。所以需要想办法还原这段js代码。 分析后发现 d获取当前时间的函数r随机数取整c内容如下methodGETtimeStamp1725264890773User-AgentMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0index8channelId40011sVersion1 可以发现就是多个信息进行拼接时间戳User-AgentindexchannelIdsVersion。f固定为keyA013F70DB97834C0A5492378BD76C53A 分析图片如下 同时我们还发现signKey是通过MD5加密cf后得到的。因为1经过MD5加密后得到的内容就是c4ca4238a0b923820dcc509a6f75849b所以我们可以猜测(0,a[i(_0x140e(0xe4))])(cf)就是一个MD5的加密。 js编写与调用 有了以上分析后我们就可以拿页面原始的js代码进行适当的改动。修改后的js代码如下我们直接返回网页负载需要的params。 添加首页cookie 在完成上面步骤后我们调用js虽然得到了params但是还是无法获得到页面的源代码这可能和cookie有关系所以我们创建一个session通过访问首页来保存首页的cookie然后再来访问这个url看看结果。 我们发现浏览器请求了两次https://www.maoyan.com/且第一次存在302跳转跳转到https://www.maoyan.com/所以是请求了两次。在python代码中我们只需要请求有302跳转的链接即可因为程序会自动进行第二次跳转。 添加cookie后使用python程序调用js代码返回params使用js生成的params去访问url地址运行结果如下 2.字体破解 字体图片下载 在拿到页面源码以后我们需要对数字进行获取。直接在返回的源码中搜索获取.woff文件。得到url//s3plus.meituan.net/v1/mss_73a511b8f91f43d0bdae92584ea6330b/font/e3dfe524.woff因为每一次请求得到的源码中woff文件的链接都不同所以我们需要使用数据提取手段提取每一次请求得到的woff文件链接并下载保存下来。 下载并保存woff文件使用python代码识别woff文件并保存为图片识别代码如下之后会整合到源码中 from fontTools.ttLib import TTFont from reportlab.graphics.shapes import Drawing, Path, Group from reportlab.graphics import renderPM from reportlab.lib import colors from reportlab.graphics.shapes import Pathclass ReportLabPen(BasePen):def init(self, glyphSet, pathNone):BasePen.init(self, glyphSet)if path is None:path Path()self.path pathdef _moveTo(self, p):(x, y) pself.path.moveTo(x, y)def _lineTo(self, p):(x, y) pself.path.lineTo(x, y)def _curveToOne(self, p1, p2, p3):(x1, y1) p1(x2, y2) p2(x3, y3) p3self.path.curveTo(x1, y1, x2, y2, x3, y3)def closePath(self):self.path.closePath()def ttfToImage(fontName, imagePath, fmtpng):font TTFont(fontName) # 打开 WOFF 字体文件gs font.getGlyphSet()glyphNames font.getGlyphNames()[1:] # 排除第一个 .notdef 字形for i in glyphNames:g gs[i] # 获取当前字形的 Glyph 对象pen ReportLabPen(gs, Path(fillcolorcolors.red, strokeWidth1)) # 创建 ReportLabPen 对象并设置相关参数g.draw(pen) # 将当前字形通过 pen 绘制到 path 对象上# 字形的宽度和高度w, h g.width, g.width 300 g Group(pen.path)g.translate(0, 100) # 将图形向下移动 100 个像素d Drawing(w, h) # 创建 Drawing 对象设置宽度和高度d.add(g) # 将 Group 对象添加到 Drawing 对象中# 定义输出图片路径和文件名imageFile f{imagePath}/{i}.{fmt}# 将 Drawing 对象渲染成图像文件并保存renderPM.drawToFile(d, imageFile, fmt)# 示例用法将 mao.woff 字体文件的字形保存为图像 ttfToImage(fontNamemao.woff, imagePathimages)识别结果如下 识别图片 识别代码如下之后会整合到源码中 import os import ddddocr # 导入 ddddocr 库def orc():# 创建一个 ddddocr 的 OCR 对象ocr ddddocr.DdddOcr()dicts {} # 初始化一个空字典用于存储识别结果lists os.listdir(./images) # 获取 images 目录下的所有文件列表# 遍历每个图片文件for imgs in lists:# 以二进制模式读取图片文件with open(./images/ imgs, rb) as f:img_bytes f.read()# 使用 OCR 对象的 classification 方法识别图片内容res ocr.classification(img_bytes)# 输出文件名中提取的 Unicode 代码print(222222222222222222, imgs[3:-4])try:# 将文件名中的 Unicode 代码转换为字符并将识别结果存入字典dicts[eval(u\\u imgs[3:-4].lower() )] resexcept:# 如果转换或存储过程中出错则跳过pass# 打印当前的字典内容print(dicts)# 调用 orc 函数 orc()字典输出结果如下 字典替换 拿到页面加密的源码然后根据字典的key来替换掉对应的数字 替换后的数字与原始页面一样 源码 py文件 import requests import execjs import re import shutil import os import ddddocr from fontTools.pens.basePen import BasePen from fontTools.ttLib import TTFont from reportlab.graphics.shapes import Drawing, Path, Group from reportlab.graphics import renderPM from reportlab.lib import colors from reportlab.graphics.shapes import Pathclass ReportLabPen(BasePen):def init(self, glyphSet, pathNone):BasePen.init(self, glyphSet)if path is None:path Path()self.path pathdef _moveTo(self, p):(x, y) pself.path.moveTo(x, y)def _lineTo(self, p):(x, y) pself.path.lineTo(x, y)def _curveToOne(self, p1, p2, p3):(x1, y1) p1(x2, y2) p2(x3, y3) p3self.path.curveTo(x1, y1, x2, y2, x3, y3)def closePath(self):self.path.closePath()def ttfToImage(fontName, imagePath, fmtpng):font TTFont(fontName) # 打开 WOFF 字体文件gs font.getGlyphSet()glyphNames font.getGlyphNames()[1:] # 排除第一个 .notdef 字形for i in glyphNames:g gs[i] # 获取当前字形的 Glyph 对象pen ReportLabPen(gs, Path(fillcolorcolors.red, strokeWidth1)) # 创建 ReportLabPen 对象并设置相关参数g.draw(pen) # 将当前字形通过 pen 绘制到 path 对象上# 字形的宽度和高度w, h g.width, g.width 300g Group(pen.path)g.translate(0, 100) # 将图形向下移动 100 个像素d Drawing(w, h) # 创建 Drawing 对象设置宽度和高度d.add(g) # 将 Group 对象添加到 Drawing 对象中# 定义输出图片路径和文件名imageFile f{imagePath}/{i}.{fmt}# 将 Drawing 对象渲染成图像文件并保存renderPM.drawToFile(d, imageFile, fmt)def download_woff():with open(猫眼.js,r,encodingutf-8) as f:ctx execjs.compile(f.read())headers_home {Accept: text/html,application/xhtmlxml,application/xml;q0.9,image/avif,image/webp,image/apng,/;q0.8,application/signed-exchange;vb3;q0.7,Accept-Language: zh-CN,zh;q0.9,en;q0.8,en-GB;q0.7,en-US;q0.6,Cache-Control: max-age0,Connection: keep-alive,Sec-Fetch-Dest: document,Sec-Fetch-Mode: navigate,Sec-Fetch-Site: none,Sec-Fetch-User: ?1,Upgrade-Insecure-Requests: 1,User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0,sec-ch-ua: \Chromium\;v\128\, \Not;ABrand\;v\24\, \Microsoft Edge\;v\128\,sec-ch-ua-mobile: ?0,sec-ch-ua-platform: \Windows}cookies_home {_lxsdk_s: 191b2c23b90-602-526-0ba%7C%7C1}url https://www.maoyan.com/s requests.session()# 访问首页保存cookier s.get(url, headersheaders_home, cookiescookies_home)headers {Accept: /,Accept-Language: zh-CN,zh;q0.9,en;q0.8,en-GB;q0.7,en-US;q0.6,Connection: keep-alive,Referer: https://www.maoyan.com/films/1464004,Sec-Fetch-Dest: empty,Sec-Fetch-Mode: cors,Sec-Fetch-Site: same-origin,User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0,X-Requested-With: XMLHttpRequest,sec-ch-ua: \Chromium\;v\128\, \Not;ABrand\;v\24\, \Microsoft Edge\;v\128\,sec-ch-ua-mobile: ?0,sec-ch-ua-platform: \Windows}url https://www.maoyan.com/ajax/films/1464004params ctx.call(get_params)response s.get(url, headersheaders, paramsparams).text# 保存woffwoff_url https: re.findall(r,url.?woff, response)[0].split()[1]woff_res s.get(woff_url).contentwith open(mao.woff, wb) as f:f.write(woff_res)f.close()result re.findall(span classstonefont(.?)/span, response)return resultdef clear_folder(folder_path):# 确保指定路径是一个文件夹if os.path.isdir(folder_path):# 遍历文件夹中的所有文件和子文件夹for filename in os.listdir(folder_path):file_path os.path.join(folder_path, filename)try:# 如果是文件则删除if os.path.isfile(file_path) or os.path.islink(file_path):os.unlink(file_path)# 如果是文件夹则删除整个文件夹elif os.path.isdir(file_path):shutil.rmtree(file_path)except Exception as e:print(f删除 {file_path} 时出错: {e})print(删除完成)def orc():# 创建一个 ddddocr 的 OCR 对象ocr ddddocr.DdddOcr()dicts {} # 初始化一个空字典用于存储识别结果lists os.listdir(./images) # 获取 images 目录下的所有文件列表# 遍历每个图片文件for imgs in lists:# 以二进制模式读取图片文件with open(./images/ imgs, rb) as f:img_bytes f.read()# 使用 OCR 对象的 classification 方法识别图片内容res ocr.classification(img_bytes)# 输出文件名中提取的 Unicode 代码print(222222222222222222, imgs[3:-4])try:# 将文件名中的 Unicode 代码转换为字符并将识别结果存入字典dicts[eval(u\\u imgs[3:-4].lower() )] resexcept:# 如果转换或存储过程中出错则跳过pass# 返回字典内容return dictsif name main:data download_woff()# 指定要清空的文件夹路径folder_path ./imagesclear_folder(folder_path)# 转换 TTF 字体并将字形转换为 PNG 图片ttfToImage(fontNamemao.woff, imagePathimages)# 使用ocr识别图片返回字典res orc()print(data)print(res)# 遍历字典并将识别结果输出for i in data:# 首先去掉所有的 #x 和 ;cleaned_str i.replace(#x, ).replace(;, )# 然后进行字符替换for key, value in res.items():cleaned_str cleaned_str.replace(key.encode(unicode_escape).decode(ascii).replace(\u, ), value)print(cleaned_str) js文件 const CryptoJS require(crypto-js)var r Mathceil var d (new Date)getTime var c methodGETtimeStampdUser-AgentMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36 Edg/128.0.0.0indexrchannelId40011sVersion1 var f keyA013F70DB97834C0A5492378BD76C53Afunction get_params(){return{timeStamp: d,index: r,signKey: CryptoJS.MD5(cf).toString(),channelId: 40011,sVersion: 1,webdriver: false} }