HTTP STATUS CODE

本文详细介绍了HTTP中常见的状态码含义,包括缓存控制相关的304状态码、不同类型的重定向(如301永久移动和302临时移动),以及常见的404未找到和500内部服务器错误等。

1 缓存相关

304, Cache-Control, Pragma, Expires,  If-Modified-Since, ETag, If-None-Match,

2 重定向

301 Move Permanently 搜索引擎记住的是response中的URL

302 Move Temporarily  搜索引擎记住的是request中的URL

303,307 是对302的扩充,对GET/POST进行了区分处理

 

3 常见

404 NOT FOUND。你懂的。现在网站流行返回一些公益广告。

500 服务器程序抛出异常啦,赶紧加班搞定。

 http://www.cnblogs.com/TankXiao/archive/2012/02/13/2342672.html

wkhtmltopdf ce.html output.pdfLoading page (1/2) Warning: Blocked access to file /usr/share/remarkable/media/highlightjs.default.min.css Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E0AB34963F1FPNFW0706_1740045746604_4281494272.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E05E36080G1FPQ3N0102_1750901910075_2823700716.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E0AB34963F1FPNFW0569_1739880983686_3304443251.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E04836080G1FPPQC1144_1750579259054_2452813871.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E0A734963F1FPNFK1370_1740275295569_3665225174.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E0A734963F1FPNFK0492_1740185733688_543816353.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E0A734963F1FPNFK1096_1740616516418_246766233.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E0AC34963F1FPNGZ0991_1737162383220_3022446520.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E0A634635F1FPNF90897_1750206882406_2254228376.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E04236080G1FPPNK2061_1750929726477_1278595401.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E06936080G1FPQ7W0698_1750666432575_3361535253.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E05L36080G1FPQ5A1962_1750993358502_56213211.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/分类错误/E05T36080G1FPPWB0047_1749868927317_2915249529.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/分类错误/E03D36080G1FPPEW0171_1749952830839_4237369372.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/分类错误/E0AB34963F1FPNFW0654_1740284158643_2500741493.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0AC34963F1FPNGZ0145_1740403419675_2969073058.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0AC34963F1FPNGZ0416_1737166251826_3536604772.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0A734963F1FPNFK1053_1740042571110_128121444.jpg Warning: Blocked access to file /usr/share/remarkable/media/highlight.min.js Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0A534963F1FPNFJ0044_1739835514791_1026479677.jpg Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0A734963F1FPNFK1245_1740707000665_2537930183.jpg Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E03636080G1FPPE10087_1750032382444_4154186674.jpg Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Printing pages (2/2)
最新发布
07-31
在使用 `wkhtmltopdf` 将 HTML 转换为 PDF 时,如果遇到资源访问被阻止和加载 `about:blank` 失败的问题,通常是由以下两个原因导致的: 1. **本地文件访问被限制**:从较新版本的 `wkhtmltopdf` 开始,默认情况下禁用了对本地文件的访问权限,这会导致 HTML 文件中引用的本地图片、CSS 或 JS 文件无法正常加载,从而出现类似 `Blocked access to file` 的警告信息[^2]。 解决方法是通过添加 `--enable-local-file-access` 参数来启用本地文件访问权限。例如,在命令行中使用以下命令进行转换: ```bash wkhtmltopdf --enable-local-file-access index.html output.pdf ``` 如果是通过 Python 的 `pdfkit` 库调用 `wkhtmltopdf`,则可以在选项中添加 `'enable-local-file-access': None`,如下所示: ```python import pdfkit options = { 'enable-local-file-access': None } pdfkit.from_file('index.html', 'output.pdf', options=options) ``` 2. **加载 `about:blank` 页面失败**:`Failed to load about:blank` 错误通常出现在 HTML 文件中引用了 `about:blank` 或者某些框架页面加载失败时。这个错误的原因是 `wkhtmltopdf` 不支持某些协议(如 `about:`),并且在某些版本中会尝试加载空白页面导致错误[^4]。 解决方法包括: - 确保 HTML 文件中没有显式引用 `about:blank` 或者不必要的框架标签。 - 如果错误不影响最终 PDF 的生成效果,可以在命令行中使用 `--no-stop-slow-scripts` 参数来忽略脚本执行超时问题,或者使用 `--quiet` 参数来抑制警告输出: ```bash wkhtmltopdf --enable-local-file-access --no-stop-slow-scripts --quiet index.html output.pdf ``` - 如果使用的是嵌入式框架或 iframe,建议将其内容内联到主 HTML 文件中,或者确保其指向的 URL 是有效的 HTTP 地址,而不是 `about:blank`。 此外,如果 HTML 文件中引用了本地路径的资源(如图片、CSS),应确保路径格式为绝对路径或完整的 `file://` 协议格式,以避免路径解析失败。例如: ```html <img src="file:///home/user/images/logo.png"> <link rel="stylesheet" href="file:///home/user/css/style.css"> ``` 这样可以提高 `wkhtmltopdf` 对本地资源的识别能力,减少加载失败的情况[^5]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值