cvedetails厂商及产品信息爬取

#!/bin/bash
domainname="http://www.cvedetails.com//product-list/vendor_id-"

echo "before while"
x=11614
while ((${x}>0))
do
 wget -O result.html $domainname${x}
 vendor=`cat result.html|grep '<title>'|cut -d '>' -f2|cut -d ':' -f1`
 # 插入数据库
resultrow="insert into t_software_vendor select ${x},'${vendor}' from dual;"
  echo $resultrow
  mysql -h 192.168.3.93 -phuawei virus -e"${resultrow}"
  echo $resultrow>>result.txt
  echo $resultrow
 count=`cat result.html|grep 'Total number of products found ='|cut -d ' ' -f 7|cut -d '&' -f1`
  let "page=${count}/50+1"
  while ((${page}>0))
  do
  wget -O result.html "$domainname${x}/page-${page}"
 
  cat result.html|tr -d '\n'|sed 's/<a href="http:\/\/www.cvedetails.com\/product/@<a href="http:\/\/www.cvedetails.com\/product/g'|tr '@' '\n'|grep '<a href="http://www.cvedetails.com/product' >final.html
  row=`wc -l final.html|cut -d ' ' -f1`
      while ((${row}>0))
      do
       productid=`tail -${row} final.html|tr -d '\n'|cut -d '/' -f5`
       productname=`tail -${row} final.html|tr -d '\n'|cut -d '>' -f2 |cut -d '<' -f1`
       producttype=`tail -${row} final.html|tr -d '\n'|cut -d '>' -f13|cut -d '<' -f1`
       # 插入数据库
       resultrow="insert into t_software_product select ${x},${productid},trim('${productname}'),trim('${producttype}') from dual;"
       echo $resultrow
       mysql -h 192.168.3.93 -phuawei virus -e"${resultrow}"
       echo $resultrow>>result.txt
       echo $resultrow    
       #控制行数  
       let "row=${row}-1"
      done 

  #控制行数
  let "page=${page}-1"
  done
let "x=${x}-1"
done 
echo done

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值