将Firefox书签(和标签)导出为CSV吗?

And*_*rew 6 firefox bookmarks

Firefox允许您导出到HTML,虽然我可以编写一个使用正则表达式将其解析为CSV的脚本,但我想知道是否存在任何允许我们直接导出为CSV的实用程序/ Firefox插件。也有兴趣是否有这样的导入方式。

sha*_*020 1

我把这个(Powershell脚本)放在一起只是为了这个问题。但我没有办法导入。请参阅我在代码中的注释以解释所发生的情况。书签确实比名称和 URL 更重要,但这些是最重要的数据,因此这就是我为 CSV 收集的所有数据。此外,您还必须将书签导出为 HTML,其作用是将其转换为 CSV 文件。

#set paths
#where your bookmarks.html is
$bkmarkPath = "C:/Users/jhancock/Desktop/test/FFbookmarks/bookmarks.html"
#where you want your CSV file to be. 
$newCSVPath = 'C:/Users/jhancock/Desktop/test/FFbookmarks/bookmarks.csv'

#get the HTML and parse it out.
$bookmarkpage = New-Object -ComObject "HTMLFile"
$bookmarkpage.IHTMLDocument2_write($(Get-content $bkmarkPath -Raw))

#get the links, and link names and put into variable.
$atags = $bookmarkpage.all.tags("a") | % innerText; 
$links = $bookmarkpage.links | % ie8_href

#clear the file if it exists  
if (Test-Path $newCSVPath) {
  clear-content $newCSVPath
}

#create a new csvfile if it doesn't exist
"""Name"",""URL""`n" | Out-File $newCSVPath -Append

#add number of lines equal to number of links
For ($i=0; $i -lt $links.length; $i++) {
    "`n"""",""""" | Out-File $newCSVPath -Append
    }

#sleep while file is created
start-sleep 2

#import our fresh CSV file
$csv = Import-Csv $newCSVPath -Header Name, URL | Select-object -skip 1

#populate our links and URLs into the CSV
$numItems = $links.Count
for ($i = 0; $i -lt $numItems; $i++) {
    $csv[$i].Name = $atags[$i]
    $csv[$i].URL = $links[$i]
}
#Generate the CSV!
$csv | Export-Csv $newCSVPath -NoTypeInformation
Run Code Online (Sandbox Code Playgroud)