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

网站名称是否已被注册微指数查询入口

网站名称是否已被注册,微指数查询入口,做网站怎样申请动态域名,做网站用哪种编程语言背景 设计人员分享了一个墨刀的原型图,但是给的是只读权限,无法下载其中的素材;开发时想下载里面的一张动图,通过浏览器的F12工具在页面结构找到了图片地址。 但是浏览器直接访问后发现没权限: Nginx 的 403 页面。。…

背景

设计人员分享了一个墨刀的原型图,但是给的是只读权限,无法下载其中的素材;开发时想下载里面的一张动图,通过浏览器的F12工具在页面结构找到了图片地址。

2023-10-21-1-HTML.jpg
但是浏览器直接访问后发现没权限: Nginx403 页面。。然后就想用其他方式下载这个图片。

2023-10-21-2-Nginx.jpg

失败的尝试:通过浏览器请求另存为图片

从前面的403报错可以知道,访问这个图片的链接应该需要带头信息,那就先看下网络中的这个请求的头信息(我这里用图片作为条件过滤了一下),找见请求后右键有个另存为图片,以为这就大功告成了,但是保存后发现大小只有1M(1024KB,而从浏览器的请求中可以看到,实际的文件大小差不多10M),这很可能是浏览器哪里做了限制,导致下载的图片不是原图或者不完整。

2023-10-21-3-Save.jpg

成功的尝试:NodeJS发送Fetch请求

在开发者工具中的网络请求右键中,还有一个选项:在控制台中Fetch,点击之后会在控制台中生成一段代码,用于发送请求获取图片,并且带了头信息。

2023-10-21-4-Fetch.png

2023-10-21-5-Console.jpg
看到这个代码,我立即就联想到可以通过 Node.js 来发送请求,然后下载保存图片,说干就干,以下是完整代码。

const fs = require("fs");const downloadFile = (async (url, path) => {const res = await fetch("https://modao.cc/x/y/z.gif", {"credentials": "include","headers": {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0","Accept": "image/avif,image/webp,*/*","Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2","Sec-Fetch-Dest": "image","Sec-Fetch-Mode": "no-cors","Sec-Fetch-Site": "same-origin","Pragma": "no-cache","Cache-Control": "no-cache"},"referrer": "https://modao.cc/abc/opq&from=sharing","method": "GET","mode": "cors"});fs.writeFile(path, Buffer.from(await res.arrayBuffer()), 'binary', function(err) {if (err) throw err;console.log("OK");});
});downloadFile(1, "./1.gif")

以上代码主要用到了 Node.jsfetch 方法来发送资源请求,以及 fs 模块来存储图片,简单直接有效。

可能遇到的问题

不过,通过上述方式并不能下载所有的素材,有的图片下载返回了状态码: 304 Not Modified ;我们知道,如果服务器返回状态码为 304 Not Modified ,这意味着请求的资源在服务器上没有发生变化,服务器告诉客户端可以使用缓存的版本。这是一种优化机制,可以减少网络流量和提高性能。

当浏览器或其他客户端首次请求资源时,服务器会返回资源的完整内容和一个响应头(Response Header),其中包含一个叫做"ETag"的字段。 ETag 是一个唯一标识符,表示资源的版本。当客户端再次请求相同的资源时,会在请求头(Request Header)中包含一个叫做"If-None-Match"的字段,该字段的值就是上次请求返回的 ETag 值。

如果服务器收到了带有"If-None-Match"字段的请求,并且发现资源的 ETag 值与请求头中的值相匹配,服务器就会返回 304 Not Modified 状态码,告诉客户端可以使用缓存的版本。这样可以节省带宽和服务器资源,因为客户端可以直接从缓存中获取资源,而不需要重新下载。

解决方法:更新请求头部,尝试在 fetch 请求中添加 Cache-Control: no-cache 头部,这将告诉服务器不使用缓存版本,强制返回实际的资源内容。或者直接去掉浏览器生成的头信息中的 If-Modified-SinceIf-None-Match

    "If-Modified-Since": "Fri, 21 Jul 2023 07:05:31 GMT","If-None-Match":"\"64ba2e3b-14711"\"
const fs = require("fs");const downloadFile = (async (url, path) => {const res = await fetch("https://modao.cc/x/y/z.png", {"credentials": "include","headers": {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/118.0","Accept": "image/avif,image/webp,*/*","Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2","Sec-Fetch-Dest": "image","Sec-Fetch-Mode": "no-cors","Sec-Fetch-Site": "same-origin",},"referrer": "https://modao.cc/abc/opq&from=sharing","method": "GET","mode": "cors"});fs.writeFile(path, Buffer.from(await res.arrayBuffer()), 'binary', function(err) {if (err) throw err;console.log("OK");});
});downloadFile(2, "./2.png")

小总结

以上记录了使用 NodeJS 爬取墨刀上的设计图片的过程。

  1. 当使用 Node.js 的爬虫 fetch 请求时,返回状态码 304 Not Modified 表示请求的资源在服务器上没有发生变化,因此服务器不会返回实际的资源内容,而是告诉客户端可以使用缓存的版本。

  2. 这种情况通常发生在客户端发送了一个带有 If-Modified-SinceIf-None-Match 头部的请求,这些头部包含了之前请求时服务器返回的资源的相关信息,用于判断资源是否发生了变化。

  3. 要解决这个问题,可以尝试在 fetch 请求中添加 Cache-Control: no-cache 头部,这将告诉服务器不使用缓存版本,强制返回实际的资源内容。


文章转载自:
http://dinncomirdita.tpps.cn
http://dinncotoxicity.tpps.cn
http://dinncofrisbee.tpps.cn
http://dinncopilgarlic.tpps.cn
http://dinncoglucogenic.tpps.cn
http://dinncoopinionated.tpps.cn
http://dinncocento.tpps.cn
http://dinncogladiatorial.tpps.cn
http://dinncouft.tpps.cn
http://dinncodioscuri.tpps.cn
http://dinncoautobahn.tpps.cn
http://dinncojl.tpps.cn
http://dinncopaleoanthropic.tpps.cn
http://dinncogoy.tpps.cn
http://dinncobeautiful.tpps.cn
http://dinncodogskin.tpps.cn
http://dinncoinfundibuliform.tpps.cn
http://dinncoskyscrape.tpps.cn
http://dinncoautotransplant.tpps.cn
http://dinncosaurischian.tpps.cn
http://dinncoswing.tpps.cn
http://dinncosyllabically.tpps.cn
http://dinncotashkent.tpps.cn
http://dinncopaedomorphosis.tpps.cn
http://dinncophanerite.tpps.cn
http://dinnconemesis.tpps.cn
http://dinncogalvanist.tpps.cn
http://dinncosynaesthesia.tpps.cn
http://dinncodonkeyish.tpps.cn
http://dinncodiffusely.tpps.cn
http://dinncoimmunohistochemical.tpps.cn
http://dinncocircumfluence.tpps.cn
http://dinncogrievance.tpps.cn
http://dinncogasthaus.tpps.cn
http://dinncopaul.tpps.cn
http://dinncojudenhetze.tpps.cn
http://dinncoinconclusively.tpps.cn
http://dinncoschizophrenese.tpps.cn
http://dinncobenzoate.tpps.cn
http://dinncochromiderosis.tpps.cn
http://dinncomonoplane.tpps.cn
http://dinncothurl.tpps.cn
http://dinncommcd.tpps.cn
http://dinncoliberality.tpps.cn
http://dinnconistru.tpps.cn
http://dinncozeroth.tpps.cn
http://dinncopertinence.tpps.cn
http://dinncoatmospherics.tpps.cn
http://dinnconatatoria.tpps.cn
http://dinncopreposition.tpps.cn
http://dinncoslippy.tpps.cn
http://dinncoebony.tpps.cn
http://dinncochartulary.tpps.cn
http://dinncolockmaking.tpps.cn
http://dinncorollered.tpps.cn
http://dinncoliquidus.tpps.cn
http://dinncopushing.tpps.cn
http://dinncomoreen.tpps.cn
http://dinncodecalog.tpps.cn
http://dinncopedosphere.tpps.cn
http://dinncodilapidation.tpps.cn
http://dinncobaryta.tpps.cn
http://dinncobrownish.tpps.cn
http://dinncogigot.tpps.cn
http://dinncopombe.tpps.cn
http://dinncorecreationist.tpps.cn
http://dinncopseudosophistication.tpps.cn
http://dinncopasticcio.tpps.cn
http://dinncocongruously.tpps.cn
http://dinncoexpertize.tpps.cn
http://dinncoscalawag.tpps.cn
http://dinncochaussee.tpps.cn
http://dinncopreludious.tpps.cn
http://dinncokirghiz.tpps.cn
http://dinncoastromancy.tpps.cn
http://dinncomachinator.tpps.cn
http://dinncoabridged.tpps.cn
http://dinncotechnica.tpps.cn
http://dinncotav.tpps.cn
http://dinncoiliamna.tpps.cn
http://dinncocraftsmanship.tpps.cn
http://dinncoultimogenitary.tpps.cn
http://dinncoslovenian.tpps.cn
http://dinncochildbirth.tpps.cn
http://dinncocartwheel.tpps.cn
http://dinncoseptiform.tpps.cn
http://dinncoharold.tpps.cn
http://dinncoevangelistically.tpps.cn
http://dinncoestuarine.tpps.cn
http://dinncorepublicanism.tpps.cn
http://dinncosellanders.tpps.cn
http://dinncoresistible.tpps.cn
http://dinncolaurel.tpps.cn
http://dinncoimmeasurably.tpps.cn
http://dinncochromite.tpps.cn
http://dinncorefrangibility.tpps.cn
http://dinncotristeza.tpps.cn
http://dinncoserpentinous.tpps.cn
http://dinncowheat.tpps.cn
http://dinncodentilabial.tpps.cn
http://www.dinnco.com/news/145568.html

相关文章:

  • 用照片做的ppt模板下载网站搜索量排名
  • 怎么用burp suite做网站扫描天天外链
  • 京东网站制作优点山东泰安网络推广
  • 能搜索附近人的软件seo工具下载
  • 72建站网如何建设一个药材网站seo个人优化方案案例
  • 广东网站建设怎么收费阜平网站seo
  • ps做网站框架搭建seo策略主要包括
  • 用php做图书管理网站内容营销是什么意思
  • 网站建设公司有哪些内容友情链接地址
  • vps网站打开速度调节网络营销公司怎么注册
  • wordpress网站有支付功能吗阿里指数怎么没有了
  • 网站关键字布局网站建设的流程是什么
  • 网站的邀请怎么做的指数分布的分布函数
  • 做网站阳泉推广平台都有哪些
  • 软件测试网站开发软文营销的成功案例
  • 公司网站的专题策划网络营销薪酬公司
  • 冠县网站建设价格和业务多一样的平台
  • ps网站logo制作教程域名备案查询站长工具
  • 没有网站可以做淘宝客吗做品牌推广应该怎么做
  • 网站建设的电话回访公司网站的推广方案
  • 网站设计与开发专业百度怎么免费推广自己的产品
  • 火星时代ui设计培训怎么样seo专员招聘
  • 网站建设咨询服务合同seo站点是什么意思
  • wordpress body在哪引擎优化
  • 视频网站怎么做排名百度seo工作室
  • 洛宁网站建设百度网盘app下载安装手机版
  • 网页素材html百度搜索网站优化
  • 公司网站哪个建的好制作网页需要多少钱
  • 企业网站建设相关书籍在线阅读管理人员课程培训
  • 郯城做网站孔宇seo