我今天频繁出现的一个论坛,经过修复后,我发现最近两天的论坛发帖已完全退回。
毋庸置疑,我想从论坛中找回我可以获得的数据,我希望我至少一些存储在Chrome创建的缓存文件中。
我面临两个问题 - 缓存文件没有文件类型,我不确定如何以智能方式阅读它们(尝试在Chrome中打开它们似乎以.gz格式“重新下载”它们),并且有一个 ton 的缓存文件。
有关如何阅读和排序这些文件的任何建议? (简单的字符串搜索应该符合我的需要)
答案 0 :(得分:31)
编辑:以下答案不再适用,请参阅here
在Chrome或Opera中,打开新标签页并导航至chrome://view-http-cache/
单击要查看的文件。 然后,您应该看到一个包含大量文本和数字的页面。 复制该页面上的所有文本。 将其粘贴在下面的文本框中。
按" Go"。 缓存的数据将显示在下面的“结果”部分中。
答案 1 :(得分:22)
从NirSoft尝试Chrome Cache View(免费)。
答案 2 :(得分:9)
编辑:以下答案不再适用,请参阅here
Chrome将缓存存储为十六进制转储。 OSX附带xxd
,这是一个用于转换十六进制转储的命令行工具。我设法使用以下步骤从OSX上的Chrome的HTTP缓存中恢复了jpg:
您的最终命令应如下所示:
pbpaste | python chrome_xxd.py | xxd -r - image.jpg
如果您不确定Chrome内容缓存输出的哪一部分是内容十六进制转储,请查看此页面以获取一个好的指南: http://www.sparxeng.com/blog/wp-content/uploads/2013/03/chrome_cache_html_report.png
图片来源:http://www.sparxeng.com/blog/software/recovering-images-from-google-chrome-browser-cache
有关XXD的更多信息:http://linuxcommand.org/man_pages/xxd1.html
感谢上面的Mathias Bynens向我发送正确的方向。
答案 3 :(得分:8)
编辑:以下答案不再适用,请参阅here
如果您尝试恢复的文件在标题部分中有Content-Encoding: gzip
,并且您使用的是Linux(或者在我的情况下,您安装了Cygwin),则可以执行以下操作:
chrome://view-http-cache/
并点击您要恢复的页面xxd -r a.txt| gzip -d
请注意,其他答案建议将-p
选项传递给xxd
- 我遇到了麻烦,大概是因为缓存的第四部分不在“postscript plain hexdump style”中,而是在“default”中样式”。
似乎没有必要用单个空格替换双空格,因为chrome_xxd.py
正在执行(如果有必要,可以使用sed 's/ / /g'
)。
答案 4 :(得分:7)
您可以单独使用Chrome阅读缓存文件。
Chrome有一项名为“显示已保存的复制按钮:
”的功能显示已保存的复制按钮 Mac,Windows,Linux,Chrome操作系统,Android
如果页面加载失败,如果浏览器缓存中存在该页面的陈旧副本,则会显示一个按钮以允许用户加载该陈旧副本。主要启用选项将按钮置于错误页面上最显着的位置;辅助启用选择将其置于重新加载按钮的辅助位置。 #节目保存的拷贝
首先断开Internet连接以确保浏览器不会覆盖缓存条目。然后导航到chrome://flags/#show-saved-copy
并将标记值设置为Enable: Primary
。重新启动浏览器后显示已保存的复制按钮将被启用。现在将缓存的文件URI插入浏览器的地址栏并按Enter键。 Chrome将显示“显示已保存的复制”按钮旁边没有Internet连接页面:
点击按钮后,浏览器将显示缓存文件。
答案 5 :(得分:3)
我对这个开源Python项目感到非常幸运,看似不活跃: https://github.com/JRBANCEL/Chromagnon
我跑了:
python2 Chromagnon/chromagnonCache.py path/to/Chrome/Cache -o browsable_cache/
我获得了所有打开标签缓存的本地浏览摘录。
答案 6 :(得分:2)
我制作了一个简短的愚蠢脚本来提取JPG和PNG文件:
#!/usr/bin/php
<?php
$dir="/home/user/.cache/chromium/Default/Cache/";//Chrome or chromium cache folder.
$ppl="/home/user/Desktop/temporary/"; // Place for extracted files
$list=scandir($dir);
foreach ($list as $filename)
{
if (is_file($dir.$filename))
{
$cont=file_get_contents($dir.$filename);
if (strstr($cont,'JFIF'))
{
echo ($filename." JPEG \n");
$start=(strpos($cont,"JFIF",0)-6);
$end=strpos($cont,"HTTP/1.1 200 OK",0);
$cont=substr($cont,$start,$end-6);
$wholename=$ppl.$filename.".jpg";
file_put_contents($wholename,$cont);
echo("Saving :".$wholename." \n" );
}
elseif (strstr($cont,"\211PNG"))
{
echo ($filename." PNG \n");
$start=(strpos($cont,"PNG",0)-1);
$end=strpos($cont,"HTTP/1.1 200 OK",0);
$cont=substr($cont,$start,$end-1);
$wholename=$ppl.$filename.".png";
file_put_contents($wholename,$cont);
echo("Saving :".$wholename." \n" );
}
else
{
echo ($filename." UNKNOWN \n");
}
}
}
?>
答案 7 :(得分:1)
chrome://cache
和chrome://view-http-cache
都已从chrome 66开始删除。它们在版本65中起作用。
您可以检查chrome://chrome-urls/
以获得内部Chrome网址的完整列表。
我想到的唯一解决方法是使用menu/more tools/developer tools
并选择一个Network
标签。
答案 8 :(得分:1)
Linux上的Google Chrome缓存目录$HOME/.cache/google-chrome/Default/Cache
在"simple entry format"中每个名为<16 char hex>_0
的缓存条目中包含一个文件:
如果您知道要查找的文件的URI,则应该很容易找到它。如果没有,那么像域名这样的子字符串应该有助于缩小范围。像这样在缓存中搜索URI:
fgrep -Rl '<URI>' $HOME/.cache/google-chrome/Default/Cache
注意:如果您未使用默认的Chrome配置文件,请用配置文件名称替换Default
,例如Profile 1
。
答案 9 :(得分:0)
JPEXS Free Flash Decompiler的Java代码可以在in the source tree上针对Chrome和Firefox进行此操作(不过,不支持Firefox的最新缓存2)。
答案 10 :(得分:0)
编辑:以下答案不再有效,请参见here
Google Chrome cache file format description。
缓存文件列表,请参阅URL(复制并粘贴到浏览器地址栏中):
chrome://cache/
chrome://view-http-cache/
Linux中的缓存文件夹:$~/.cache/google-chrome/Default/Cache
让我们确定文件的GZIP编码:
$ head f84358af102b1064_0 | hexdump -C | grep --before-context=100 --after-context=5 "1f 8b 08"
在PHP上一行提取Chrome缓存文件(不带标题,CRC32和ISIZE块):
$ php -r "echo gzinflate(substr(strchr(file_get_contents('f84358af102b1064_0'), \"\x1f\x8b\x08\"), 10,
-8));"
答案 11 :(得分:0)
Joachim Metz为some documentation of the Chrome cache file format提供了更多信息的参考。
对于我的用例,我只需要一个缓存的URL及其相应时间戳的列表。我写了一个Python脚本来解析C:\Users\me\AppData\Local\Google\Chrome\User Data\Default\Cache\
下的data_ *文件:
import datetime
with open('data_1', 'rb') as datafile:
data = datafile.read()
for ptr in range(len(data)):
fourBytes = data[ptr : ptr + 4]
if fourBytes == b'http':
# Found the string 'http'. Hopefully this is a Cache Entry
endUrl = data.index(b'\x00', ptr)
urlBytes = data[ptr : endUrl]
try:
url = urlBytes.decode('utf-8')
except:
continue
# Extract the corresponding timestamp
try:
timeBytes = data[ptr - 72 : ptr - 64]
timeInt = int.from_bytes(timeBytes, byteorder='little')
secondsSince1601 = timeInt / 1000000
jan1601 = datetime.datetime(1601, 1, 1, 0, 0, 0)
timeStamp = jan1601 + datetime.timedelta(seconds=secondsSince1601)
except:
continue
print('{} {}'.format(str(timeStamp)[:19], url))