加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

powershell获取商品标题

发布时间:2020-12-15 20:54:07 所属栏目:安全 来源:网络整理
导读:实现效果: 实现代码: function Get-ItemList( $page ){ $url_login =‘http://******.***.lcweb03.cn/ master_72gs5v‘ $url_info =‘http://******.***.lcweb03.cn/goods/index?shop_type=1page=‘+ $page $headers = @ { ‘Accept‘ =‘application/json

实现效果:

  

实现代码:

function Get-ItemList($page)
{

    $url_login=‘http://******.***.lcweb03.cn/master_72gs5v‘
    $url_info=‘http://******.***.lcweb03.cn/goods/index?shop_type=1&page=‘+$page

    $headers = @{
    ‘Accept‘=‘application/json,text/javascript,*/*; q=0.01‘;
    ‘User-Agent‘=‘Mozilla/5.0 (Windows NT 10.0) AppleWebKit/537.36 (KHTML,like Gecko) Chrome/74.0.3729.108 Safari/537.36#add cookie 
    ‘Cookie‘=‘workspaceParam=0%7C1%7Cgoods%2Findex; PHPSESSID=uc3jr6r87oun5pbrljip1lddr9‘
    }

    $headers_2 = @{
    ‘Cookie‘=‘PHPSESSID=uc3jr6r87oun5pbrljip1lddr9‘
    }

    $date[email?protected]{
    nickname=‘username‘;
    password=‘passworld‘
    }
    $null=[void]{Invoke-RestMethod -Uri $url_login -Method Post -Body $date -Headers $headers -SessionVariable session}
    $con=Invoke-RestMethod -Uri $url_info -Method Get -Headers $headers_2 -WebSession $session
            $a=([regex]::Matches($con,‘<div class="name-div" title=(.*?)>‘))
    $a=[regex]::Matches($con,‘<div class="name-div" title=(.*?)>‘)
    [regex]::Replace($a.groups.GetEnumerator().value,‘<div class="name-div" title=(.*?)>‘,‘‘)
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读