标题: [问题求助] [已解决]GPT生成的vbs代码txt合并内容去空行、删除重复项无效求助 [打印本页]
作者: smdx 时间: 2024-9-7 10:39 标题: [已解决]GPT生成的vbs代码txt合并内容去空行、删除重复项无效求助
目的是把多个Tracker 服务器下载合并到一个txt文档去除空行和重复项。
用GPT生成的vbs脚本去空行、删除重复项无效,请问大佬们要怎么修改?谢谢- Dim objFSO, objShell, objHTTP, strURL, strContent, arrURLs, line, uniqueContent
-
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objShell = CreateObject("WScript.Shell")
- Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
-
- ' 创建一个字典对象用于存储唯一内容
- Set uniqueContent = CreateObject("Scripting.Dictionary")
-
- ' 定义要下载内容的URL数组
- arrURLs = Array( _
- "https://raw.githubusercontent.com/Tunglies/TrackersList/main/all.txt", _
- "https://cf.trackerslist.com/best.txt", _
- "https://raw.adysec.com/adysec/tracker/main/trackers_best.txt", _
- "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt", _
- "https://raw.githubusercontent.com/DeSireFire/animeTrackerList/master/AT_all_https.txt" _
- )
-
- ' 遍历每个URL,下载内容并合并到uniqueContent中
- For Each strURL In arrURLs
- objHTTP.open "GET", strURL, False
- objHTTP.send
-
- If objHTTP.Status = 200 Then
- strContent = objHTTP.ResponseText
- For Each line In Split(strContent, vbCrLf)
- ' 排除空行
- If Trim(line) <> "" Then
- If Not uniqueContent.Exists(line) Then
- uniqueContent.Add line, ""
- End If
- End If
- Next
- End If
- Next
-
- ' 将合并的内容写入文件
- Set objOutputFile = objFSO.CreateTextFile("combined_content.txt", True)
- For Each item In uniqueContent.Keys
- objOutputFile.WriteLine(item)
- Next
- objOutputFile.Close
-
- Set objFSO = Nothing
- Set objShell = Nothing
- Set objHTTP = Nothing
- Set uniqueContent = Nothing
复制代码
作者: flashercs 时间: 2024-9-7 11:28
- Dim objFSO, objShell, objHTTP, strURL, strContent, arrURLs, line, uniqueContent
-
- Set objFSO = CreateObject("Scripting.FileSystemObject")
- Set objShell = CreateObject("WScript.Shell")
- Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
-
- ' 创建一个字典对象用于存储唯一内容
- Set uniqueContent = CreateObject("Scripting.Dictionary")
-
- ' 定义要下载内容的URL数组
- arrURLs = Array( _
- "https://raw.githubusercontent.com/Tunglies/TrackersList/main/all.txt", _
- "https://cf.trackerslist.com/best.txt", _
- "https://raw.adysec.com/adysec/tracker/main/trackers_best.txt", _
- "https://raw.githubusercontent.com/ngosang/trackerslist/master/trackers_best.txt", _
- "https://raw.githubusercontent.com/DeSireFire/animeTrackerList/master/AT_all_https.txt" _
- )
-
- ' 遍历每个URL,下载内容并合并到uniqueContent中
- For Each strURL In arrURLs
- objHTTP.open "GET", strURL, False
- objHTTP.send
-
- If objHTTP.Status = 200 Then
- strContent = objHTTP.ResponseText
- For Each line In Split(strContent, vbLf) '换行符是\n
- ' 排除空行
- If Trim(line) <> "" Then
- If Not uniqueContent.Exists(line) Then
- uniqueContent.Add line, ""
- End If
- End If
- Next
- End If
- Next
-
- ' 将合并的内容写入文件
- Set objOutputFile = objFSO.CreateTextFile("combined_content.txt", True)
- For Each item In uniqueContent.Keys
- objOutputFile.WriteLine item
- Next
- objOutputFile.Close
-
- Set objFSO = Nothing
- Set objShell = Nothing
- Set objHTTP = Nothing
- Set uniqueContent = Nothing
复制代码
作者: smdx 时间: 2024-9-7 11:41
回复 2# flashercs
非常感谢,完美解决。
欢迎光临 批处理之家 (http://bathome.net./) |
Powered by Discuz! 7.2 |