[新手上路]批处理新手入门导读[视频教程]批处理基础视频教程[视频教程]VBS基础视频教程[批处理精品]批处理版照片整理器
[批处理精品]纯批处理备份&还原驱动[批处理精品]CMD命令50条不能说的秘密[在线下载]第三方命令行工具[在线帮助]VBScript / JScript 在线参考
返回列表 发帖

红包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

  1. @set @n=0/*&echo off
  2. set "Afile=a.txt"
  3. set "Bfile=b.txt"
  4. >"%Bfile%" (for /f "delims=" %%a in ('type "%Afile%"^|cscript -nologo -E:jscript "%~f0"') do echo;%%a)
  5. pause&exit */
  6. while(!WSH.StdIn.AtEndOfStream)
  7. {
  8. line=WSH.StdIn.ReadLine();
  9. var ln=line.replace(/\"GoodsLink\":\"([^\"]+)/gim,function(){
  10. WSH.Echo(arguments[1]);
  11. })
  12. }
复制代码
QQ 33892006

TOP

本帖最后由 xczxczxcz 于 2018-8-29 18:29 编辑

该帖打广告?
来个平民式的普通脚本。
到本论坛下载 一个  http://batch-cn.qiniudn.com/tool/1.12/enca.exe
把上面的程序解压出 1个exe 和 2个dll 出来,把这3个文件和批处理放在一起。
  1. @echo off & setlocal EnableDelayedExpansion
  2. cd/d "%~dp0"
  3. 2>nul enca -L zh_cn a.txt|findstr /i /c:"UTF-8">nul 2>&1 && chcp 65001>nul|| chcp 936>nul
  4. cd.>b.txt
  5. for /f "delims=" %%a in (a.txt) do (
  6. set "string=%%a"
  7. set "string=!string:GoodsLink":"=㊣!"
  8. set "string=!string:","ActLink=㊣!"
  9. call :LOOP !string!
  10. )
  11. pause & exit
  12. :LOOP
  13. for /f "tokens=1* delims=㊣" %%a in ("!string!") do (
  14. set "name=%%a"
  15. if /i "!name:~0,4!"=="http" echo %%a>>b.txt
  16. if "%%b" neq "" (
  17. set "string=%%b"
  18. goto LOOP
  19. )
  20. )
复制代码
========================================

TOP

用grep
  1. grep -Po '(?<=GoodsLink\":\")http.*?(?=\",\"ActLink)' a.txt >b.txt
复制代码
如果是在cmd下运行 最外面的' 要改成“

TOP

  1. @echo off
  2. powershell "$txt=gc 'a.txt';[regex]::matches($txt,'(?<=\"GoodsLink\":\")[^^\"]+')|%%{$_.value}">"b.txt"
  3. pause
复制代码
1

评分人数

提供bat代写,为你省时省力省事,支付宝扫码头像支付
微信: unique2random

TOP

返回列表