标题: [文本处理] [已解决]批量提取文本里面的png图片链接并输出到新的文本中? [打印本页]
作者: a574045075 时间: 2024-8-10 13:29 标题: [已解决]批量提取文本里面的png图片链接并输出到新的文本中?
本帖最后由 a574045075 于 2024-8-10 14:34 编辑
- src="https://cdn.wikimg.net/en/zeldawiki/images/thumb/a/ab/Aftermath.png/120px-Aftermath.png" decoding="async" loading="lazy" width="120" height="103" srcset="//cdn.wikimg.net/en/zeldawiki/images/thumb/a/ab/Aftermath.png/180px-Aftermath.png 1.5x, //cdn.wikimg.net/en/zeldawiki/images/thumb/a/ab/Aftermath.png/240px-Aftermath.png 2x" /></a></span></div>
- <div class="gallerytext">
- <a href="/wiki/File:Aftermath.png" class="galleryfilename galleryfilename-truncate" title="File:Aftermath.png">Aftermath.png</a>
- 400 × 344; 142 KB<br />
-
- </div>
- </li>
- <li class="gallerybox" style="width: 155px">
- <div class="thumb" style="width: 150px; height: 150px;"><span typeof="mw:File"><a href="/wiki/File:Fishing_Hook_Screenshot.png" class="mw-file-description"><img alt="" src="https://cdn.wikimg.net/en/zeldawiki/images/thumb/8/8a/Fishing_Hook_Screenshot.png/120px-Fishing_Hook_Screenshot.png" decoding="async" loading="lazy" width="120" height="96" srcset="//cdn.wikimg.net/en/zeldawiki/images/8/8a/Fishing_Hook_Screenshot.png 1.5x" /></a></span></div>
- <div class="gallerytext">
- <a href="/wiki/File:Fishing_Hook_Screenshot.png" class="galleryfilename galleryfilename-truncate" title="File:Fishing Hook Screenshot.png">Fishing Hook Screenshot.png</a>
- 160 × 128; 2 KB<br />
复制代码
如何把上面代码里面的图片链接批量提取并输出到新文本中?
结果如下- https://cdn.wikimg.net/en/zeldawiki/images/thumb/a/ab/Aftermath.png/120px-Aftermath.png
- https://cdn.wikimg.net/en/zeldawiki/images/thumb/8/8a/Fishing_Hook_Screenshot.png/120px-Fishing_Hook_Screenshot.png
复制代码
作者: hlzj88 时间: 2024-8-10 13:48
http://bcn.bathome.net/s/tool/index.html?down&key=sedsed下载- chcp 65001 是否需要根据调试
- sed -i "s/http/\nhttp/g;s/png\"/png\n/g" test.txt
- chcp 936 是否需要根据调试
- findstr /i "https" test.txt|findstr -i "png">>test2.txt
复制代码
是否需要保存为ansi格式的bat,需实际测试确定。
如上 ,现状我系统win11,这些调试比较头疼。
作者: aloha20200628 时间: 2024-8-10 14:26
本帖最后由 aloha20200628 于 2024-8-10 14:31 编辑
回复 1# a574045075
- @echo off &(for /f "delims=" %%a in ('findstr /ic:"src=" 1.xml') do (
- set "s=%%a"&setlocal enabledelayedexpansion
- for /f tokens^=2^delims^=^" %%v in ("!s:*src=!") do echo,%%v
- endlocal
- ))>1.txt
- pause&exit/b
复制代码
作者: a574045075 时间: 2024-8-10 14:36
回复 2# hlzj88
谢谢! win7测试通过.
作者: WHY 时间: 2024-8-10 15:18
http://bcn.bathome.net/tool/3.0/grep.exe- grep -Po "(?<=src=\x22)https?[^\x22]+(?=\x22)" a.txt | find /v "" > b.txt
复制代码
欢迎光临 批处理之家 (http://www.bathome.net/) |
Powered by Discuz! 7.2 |