Skip to content

Instantly share code, notes, and snippets.

@turicas
Last active November 2, 2020 11:19
Show Gist options
  • Save turicas/7c7fe143fba270271c4df1ca4d357006 to your computer and use it in GitHub Desktop.
Save turicas/7c7fe143fba270271c4df1ca4d357006 to your computer and use it in GitHub Desktop.
SQL file to extract all Brazilian domains from Chrome history using Chrome's SQLite database

Extract Brazilian Domains from Google Chrome History

Save the chrome-history.sql file and then execute on the terminal:

CHROME_DB=~/.config/google-chrome/Default/History
cat chrome-history.sql | sqlite3 $CHROME_DB

Then access the data in my-chrome-history.csv.

.headers on
.mode csv
.output my-chrome-history.csv
SELECT
DISTINCT CASE
WHEN INSTR(domain, ':') = 0 THEN domain
ELSE substr(domain, 1, instr(domain, ':') - 1)
END AS domain
FROM (
SELECT
DISTINCT SUBSTR(SUBSTR(url, INSTR(url, '//') + 2), 1, INSTR(SUBSTR(url, INSTR(url, '//') + 2), '/') - 1) AS domain
FROM urls
WHERE
url LIKE 'http%' AND
(domain LIKE '%.br' OR domain LIKE '%.br:%')
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment