【发布时间】:2019-06-21 17:10:17
【问题描述】:
我正在尝试创建一个脚本来检索我的所有浏览器历史记录,问题是我无法使用确切的链接和访问网站的日期时间使其工作。
有人可以帮我吗?
我已经尝试过这个页面,但仍然无法获取日期时间/完整的链接信息。
Export Chrome History with Powershell
function Get-ChromeHistory {
$Path = "$Env:systemdrive\Users\$UserName\AppData\Local\Google\Chrome\User Data\Default\History"
if (-not (Test-Path -Path $Path)) {
Write-Verbose "[!] Could not find Chrome History for username: $UserName"
}
$Regex = '(htt(p|s))://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)*?'
$Value = Get-Content -Path "$Env:systemdrive\Users\$UserName\AppData\Local\Google\Chrome\User Data\Default\History"|Select-String -AllMatches $regex |% {($_.Matches).Value} |Sort -Unique
$Value | ForEach-Object {
$Key = $_
if ($Key -match $Search){
New-Object -TypeName PSObject -Property @{
User = $UserName
Browser = 'Chrome'
DataType = 'History'
Data = $_
}
}
}
}
实际结果:
Chrome | myusername | https://www.stackoverflow.com/
预期结果:
Chrome | username | 06/21/2019 11:05 | https://stackoverflow.com/questions/ask
【问题讨论】:
-
您提供的代码仅从 Chrome 的历史记录 SQLLite DB 中提取 URL,而不是日期。除非您使用 SQLLite 应用程序或 System.Data.SQLite 等库之一,否则解析与 URL 关联的日期将非常困难
-
对于 .NET,请参阅 this extension。您可以使用它与 sqllite db 进行交互。
标签: powershell google-chrome browser-history