zoukankan      html  css  js  c++  java
  • powershell获取商品标题

    实现效果:

      

    实现代码:

    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=@{
        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=(.*?)>','')
    }
  • 相关阅读:
    python-04
    python-03
    python-02
    python-01
    day4-RHCS
    python 之元组(tuple)
    11.21
    python之猜数小游戏
    python之简陋的数据库
    11.20
  • 原文地址:https://www.cnblogs.com/feiyucha/p/11181730.html
Copyright © 2011-2022 走看看