【问题标题】:Export Firefox bookmarks (and tags) to CSV?将 Firefox 书签(和标签)导出为 CSV?
【发布时间】:2019-04-28 17:53:40
【问题描述】:

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

【问题讨论】:

  • 你要导出多少行..??/

标签: firefox bookmarks


【解决方案1】:

我相信这样的扩展目前还不存在,但我想让您知道,您还可以将书签导出为 JSON 格式,与使用 HTML 导出 (. .. 取决于)。

Mozilla 的官方 Firefox 支持页面 Restore bookmarks from backup or move them to another computer 在“手动备份”下提到了如何执行此操作,尽管我发现通过浏览器菜单栏导航更容易:
Bookmarks > Show All Bookmarks,单击星形按钮并选择 @ 987654324@。这将提示保存文件对话框,其中包含一个名为 bookmarks-YYYY-MM-DD.json 的 JSON 文件,其中包含当前日期。

编辑:最接近使用 FF 插件的解决方案可能是 JavaScript 小书签。我包含了第一个简单版本in a Gist over on GitHub 的代码。您可以在浏览器中打开书签的 HTML 导出来运行它。

【讨论】:

    【解决方案2】:

    我把这个(Powershell 脚本)放在一起只是为了这个问题。我没有办法导入。请参阅代码中的我的 cmets 以了解正在发生的事情。书签确实比名称和 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
    

    【讨论】:

    • 我想补充一下,我也在 Chrome 和 MS-Edge 的导出上测试了这个,这也成功地将这些书签导出转换为 CSV。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-10-18
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-10
    相关资源
    最近更新 更多