标题: 红包10元,求个提取指定关键词之间内容的BAT,谢谢 [打印本页]
作者: as5627127 时间: 2018-8-29 14:13 标题: 红包10元,求个提取指定关键词之间内容的BAT,谢谢
{"error":0,"total_num":91,"msg":"ok","data":[{"ID":785609,"GoodsId":"559313414155","GoodsName":"【第二件1元】香菇拌饭酱200g*2瓶","GoodsClass":"","GoodsLink":"https://detail.tmall.com/item.htm?id=559313414155","ActLink":"http://uland.taobao.com/quan/detail?sellerId=3410352649&activityId=78dfc141996347c6b848d0a4f1ac8365","ImgUrl":"https://img.alicdn.com/imgextra/i3/3410352649/O1CN011VRHczQSodQz5yJ_!!3410352649.jpg","ActMoney":3.00,"GoodsPrice":19.80,"LastPrice":16.80,"BeginDate":"2018-08-29 13:09:29","EndDate":"2018-09-01 23:59:59","SaleCount":50890,"TKMoneyRate":30.00,"TjRemark":"【第二件1元】拍2件共发4瓶只要15.8,平均3.9元,线下超市一瓶都要9块钱!大颗香菇,嚼劲十足,吃出肉的感觉,可拌饭、拌面、蘸酱料都超好吃!2.7万高分好评,速抢!!【赠运费险】","Coupon_Count":20000,"Coupon_SaleCount":7200,"ly":1,"MarketImage":"https://img.alicdn.com/imgextra/i3/3410352649/O1CN011VRHczQSodQz5yJ_!!3410352649.jpg","ActivityType":0,"OrderCount":2739,"TowHourCount":9658,"AllDayCount":14353,"SellerId":"0","CommssionType":0},{"ID":759491,"GoodsId":"566705404858","GoodsName":"佰草世家补水保湿祛痘洗面奶*3瓶","GoodsClass":"","GoodsLink":"https://detail.tmall.com/item.htm?id=566705404858","ActLink":"http://uland.taobao.com/quan/detail?sellerId=1055530397&activityId=d1493b08d7aa46478665e415f9f01647","ImgUrl":"https://img.alicdn.com/bao/uploaded/i3/1055530397/TB1kNMegyCYBuNkHFCcXXcHtVXa_!!0-item_pic.jpg","ActMoney":40.00,"GoodsPrice":49.90,"LastPrice":9.90,"BeginDate":"2018-08-29 13:09:29","EndDate":"2018-09-01 23:59:59","SaleCount":268947,"TKMoneyRate":60.00,"TjRemark":"【月销24万 50万好评】纯天然植物配方,温和洁面,水润保湿,深层清洁,平衡水油,美白肌肤,淡斑提亮,一款能祛斑的洗面
提取 GoodsLink 和 ActLink 之间的网址保存到新的文本里,一行一个
原文本a.txt 新文本b.txt
保存格式:
https://detail.tmall.com/item.htm?id=559313414155
https://detail.tmall.com/item.htm?id=566705404858
作者: zaqmlp 时间: 2018-8-29 14:21
- @echo off
- powershell "$txt=gc 'a.txt';[regex]::matches($txt,'(?<=\"GoodsLink\":\")[^^\"]+')|%%{$_.value}">"b.txt"
- pause
复制代码
作者: cfwyy77_bat 时间: 2018-8-29 16:12
用grep- grep -Po '(?<=GoodsLink\":\")http.*?(?=\",\"ActLink)' a.txt >b.txt
复制代码
如果是在cmd下运行 最外面的' 要改成“
作者: xczxczxcz 时间: 2018-8-29 17:27
本帖最后由 xczxczxcz 于 2018-8-29 18:29 编辑
该帖打广告?
来个平民式的普通脚本。
到本论坛下载 一个 http://batch-cn.qiniudn.com/tool/1.12/enca.exe
把上面的程序解压出 1个exe 和 2个dll 出来,把这3个文件和批处理放在一起。- @echo off & setlocal EnableDelayedExpansion
- cd/d "%~dp0"
- 2>nul enca -L zh_cn a.txt|findstr /i /c:"UTF-8">nul 2>&1 && chcp 65001>nul|| chcp 936>nul
-
- cd.>b.txt
- for /f "delims=" %%a in (a.txt) do (
- set "string=%%a"
- set "string=!string:GoodsLink":"=㊣!"
- set "string=!string:","ActLink=㊣!"
- call :LOOP !string!
- )
- pause & exit
-
- :LOOP
- for /f "tokens=1* delims=㊣" %%a in ("!string!") do (
- set "name=%%a"
- if /i "!name:~0,4!"=="http" echo %%a>>b.txt
- if "%%b" neq "" (
- set "string=%%b"
- goto LOOP
- )
- )
复制代码
========================================
作者: yhcfsr 时间: 2018-8-29 18:56
- @set @n=0/*&echo off
- set "Afile=a.txt"
- set "Bfile=b.txt"
-
- >"%Bfile%" (for /f "delims=" %%a in ('type "%Afile%"^|cscript -nologo -E:jscript "%~f0"') do echo;%%a)
- pause&exit */
-
- while(!WSH.StdIn.AtEndOfStream)
- {
- line=WSH.StdIn.ReadLine();
- var ln=line.replace(/\"GoodsLink\":\"([^\"]+)/gim,function(){
- WSH.Echo(arguments[1]);
- })
- }
复制代码
欢迎光临 批处理之家 (http://bbs.bathome.net/) |
Powered by Discuz! 7.2 |