Save URL and title of Web Video

Hello, everyone. I am learning to use uni.vision recently. I plan to write a script to get the URLs and titles of all the works on the user’s home page, and finally save them to CSV. But in the implementation process, I always report an error “[error] line 10: error in runeval code: unexpected token ‘{’”. How can I modify it? Thank you very much for your help! Here is my JSON Code:

{
  "Name": "14",
  "CreationDate": "2025-8-12",
  "Commands": [
    {
      "Command": "open",
      "Target": "https://www.douyin.com/user/MS4wLjABAAAA-JyMuj8-Y1zdeOKe3EmOhNsACVyOGRjy2WKXAfBqp8A",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "waitForPageToLoad",
      "Target": "15000",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "storeEval",
      "Target": "0",
      "Value": "lastCount",
      "Description": ""
    },
    {
      "Command": "label",
      "Target": "scrollLoop",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "document.querySelector('div[data-e2e=\"user-post-list\"]').scrollTop=document.querySelector('div[data-e2e=\"user-post-list\"]').scrollTop+800",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "pause",
      "Target": "1500",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "storeEval",
      "Target": "document.querySelectorAll('div[data-e2e=\"user-post-list\"] a[href*=\"/video/\"]').length",
      "Value": "currentCount",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "return document.querySelectorAll('div[data-e2e=\"user-post-list\"] a[href*=\"/video/\"]').length > parseInt('${lastCount}');",
      "Value": "shouldContinue",
      "Description": ""
    },
    {
      "Command": "if",
      "Target": "${shouldContinue}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "storeEval",
      "Target": "${currentCount}",
      "Value": "lastCount",
      "Description": ""
    },
    {
      "Command": "gotoLabel",
      "Target": "scrollLoop",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "var cards = document.querySelectorAll('div[data-e2e=\"user-post-list\"] a[href*=\"/video/\"]'); var arr=[]; for(var i=0;i<cards.length;i++){ arr.push(i); } return arr;",
      "Value": "indexList",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "return [['视频URL','标题']];",
      "Value": "csvHeader",
      "Description": ""
    },
    {
      "Command": "csvSaveArray",
      "Target": "csvHeader",
      "Value": "douyin_videos",
      "Description": ""
    },
    {
      "Command": "forEach",
      "Target": "idx",
      "Value": "indexList",
      "Description": ""
    },
    {
      "Command": "storeEval",
      "Target": "document.querySelectorAll('div[data-e2e=\"user-post-list\"] a[href*=\"/video/\"]')[parseInt('${idx}')].href",
      "Value": "fullUrl",
      "Description": ""
    },
    {
      "Command": "storeEval",
      "Target": "var el = document.querySelectorAll('div[data-e2e=\"user-post-list\"] a[href*=\"/video/\"]')[parseInt('${idx}')]; var p = el.querySelector('p[class*=\"video-title\"]'); return p ? p.textContent.trim() : '';",
      "Value": "title",
      "Description": ""
    },
    {
      "Command": "executeScript",
      "Target": "return [[window.fullUrl, window.title]];",
      "Value": "row",
      "Description": ""
    },
    {
      "Command": "csvSaveArray",
      "Target": "row",
      "Value": "douyin_videos",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "已写入:${title}",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "end",
      "Target": "",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "csvSave",
      "Target": "douyin_videos",
      "Value": "",
      "Description": ""
    },
    {
      "Command": "echo",
      "Target": "全部完成!结果已保存到 douyin_videos.csv",
      "Value": "",
      "Description": ""
    }
  ]
}

I see you are using the deprecated command “storeEval” - why? Better use executeScript instead!

1 Like

Ah, hahaha, because I just started learning and am not proficient in the grammar of uni.vision, I asked GPT, but I didn’t understand it very well. It’s a bit embarrassing, hahaha.

1 Like

Sorry to bother you, could you please write a JSON code to extract the URL and title of a video to the CSV file according to the URL of my code? I would very much like to see what the standard practice is. I will sincerely thank you for your help!