首页 > 解决方案 > Webscraping 本地 Web 应用程序,尝试使用 Powershell 更新 JSON 对象

问题描述

我正在做一个项目。我有一个从网络抓取中提取的 JSON 对象。网络是我正在处理的内容的 html 版本,用于查看当前电影以及是否将其添加到我的 IMDB 观看列表中。:

        {
         "title": "The Gallows Act II",
         "alternativeTitles": [],
         "secondaryYearSourceId": 0,
         "sortTitle": "gallows act ii",
         "status": "released",
         "overview": "When Ana Rue transfers to a prestigious 
new acting school, she encounters a                                           malevolent spirit after participating in a viral challenge.",
         "inCinemas": "2019-10-25T05:00:00Z",
         "physicalRelease": "2019-10-25T00:00:00Z",
         "physicalReleaseNote": "",
         "images": [
         {
         "coverType": "poster",
         "url": "/MediaCover/54956/poster.jpg"
         },
      {
        "coverType": "fanart",
        "url": "/MediaCover/54956/fanart.jpg"
      }
    ],
    "website": "",
    "year": 2019,
    "studio": "Tremendum Pictures",
    "profileId": 1,
    "pathState": "dynamic",
    "monitored": true,
    "minimumAvailability": "inCinemas",
    "isAvailable": true,
    "runtime": 99,
    "lastInfoSync": "2020-01-28T16:40:11.982967Z",
    "cleanTitle": "thegallowsactii",
    "imdbId": "tt7473716",
    "tmdbId": 505060,
    "titleSlug": "the-gallows-act-ii-505060",
    "genres": [],
    "tags": [],
    "ratings": {
      "votes": 12,
      "value": 5.3
    },

$address="http://localhost:PORT" 
$movie_id = ""
#$movie_title = Read-Host "Movie Title"
$params = @{"name"="RescanMovie";"movieId"="$movie_id";} | ConvertTo-Json
$apikey = 'APIKEY FOR APPLICATION'

$converted = Invoke-WebRequest -URI "$address/api/movie/" -Method GET/(10) -UseBasicParsing        -Header @{"X-Api-Key" = $apikey} 
$converted 
#$convertto = Invoke-WebRequest -URI "$address/api/movie/" -Method PUT -UseBasicParsing -Header    @{"X-Api-Key" = $apikey} 

现在我使用 API pull 提取这些信息:Invoke-Webrequest。

然而。我不确定如何在 powershell 中执行 POST 命令来更新整个列表并将其传回。

标签: jsonpowershellput

解决方案


推荐阅读