Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Parsing 我正在尝试使用Powershell解析非标准rss提要_Parsing_Powershell_Rss_Pinterest - Fatal编程技术网

Parsing 我正在尝试使用Powershell解析非标准rss提要

Parsing 我正在尝试使用Powershell解析非标准rss提要,parsing,powershell,rss,pinterest,Parsing,Powershell,Rss,Pinterest,我的Pinterest提要将RSS标题截断为20个字符,我需要解析出“img src”和描述末尾的较长文本 我的代码非常简单,但我不知道如何让我的新标题写上“为什么你必须要有一个“电梯”#推销-#营销” 我也尝试过调用WebRequest,这对基本检索有效,但对描述的解析让我感到困惑 我的提要如下(RSS的一行): 你为什么要这么做ahttp://pinterest.com/pin/329888741425045427/ pa href=”http://pinterest.com/pin/32

我的Pinterest提要将RSS标题截断为20个字符,我需要解析出“img src”和描述末尾的较长文本

我的代码非常简单,但我不知道如何让我的新标题写上“为什么你必须要有一个“电梯”#推销-#营销”

我也尝试过调用WebRequest,这对基本检索有效,但对描述的解析让我感到困惑

我的提要如下(RSS的一行):

你为什么要这么做ahttp://pinterest.com/pin/329888741425045427/  pa href=”http://pinterest.com/pin/329888741425045427/“img src=”http://media-cache-lt0.pinterest.com/192x/bd/5e/7c/bd5e7cd628c21313d835a4e5c89d28ee.jpg“/a/pp为什么你必须有一个#电梯#推销#营销/p周三,2013年3月6日21:59:55+0000http://pinterest.com/pin/329888741425045427/ 

任何帮助都将不胜感激

我想这就是你要找的

$feed.rss.channel.Item | 
    select -Property link, description, @{
        n = 'title'
        e = {[regex]::Matches($_.description, '<p>(.+?)</p>')[1].Groups[1].Value}
     } | ogv
$feed.rss.channel.Item |
选择-属性链接、说明、@{
n=‘标题’
e={[regex]::匹配($uz.description,“(.+?)

”)[1]。组[1]。值} }| ogv
这将使用一个具有n(名称)和e(表达式)键的哈希表创建一个自定义属性。

可能是这样吗

$feed.rss.channel.item | %{ 
   if ($_.description -match '.*<img src="([^"]+)".*<p>(.*)</p>') { 
      $_.title = $matches[2];
      $_.link = $matches[1] 
   } 
   $_ 
} | select title, link, description | Out-GridView
$feed.rss.channel.item |%{
如果($说明-匹配'.*(.*)

'){ $\ title=$匹配项[2]; $\链接=$匹配项[1] } $_ }|选择标题、链接、描述|输出网格视图
希望这有帮助


/弗雷德里克

这个答案最有利于获得img和全名。真是太棒了!非常感谢弗里登!你也帮我安迪:}
$feed.rss.channel.Item | 
    select -Property link, description, @{
        n = 'title'
        e = {[regex]::Matches($_.description, '<p>(.+?)</p>')[1].Groups[1].Value}
     } | ogv
$feed.rss.channel.item | %{ 
   if ($_.description -match '.*<img src="([^"]+)".*<p>(.*)</p>') { 
      $_.title = $matches[2];
      $_.link = $matches[1] 
   } 
   $_ 
} | select title, link, description | Out-GridView