]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/html_attribute.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 21 Jun 2018 22:33:36 +0000 (23:33 +0100)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Thu, 21 Jun 2018 22:33:36 +0000 (23:33 +0100)
lib/postgres/html_attribute.sql [new file with mode: 0644]
lib/postgres/html_tag.sql

diff --git a/lib/postgres/html_attribute.sql b/lib/postgres/html_attribute.sql
new file mode 100644 (file)
index 0000000..aabb218
--- /dev/null
@@ -0,0 +1,19 @@
+DROP TABLE IF EXISTS html_attribute;
+CREATE TABLE IF NOT EXISTS html_attribute (
+  name varchar(100) PRIMARY KEY,
+  description varchar(500),
+  link varchar(200)
+);
+BEGIN TRANSACTION;
+DELETE FROM html_attribute;
+COPY html_attribute (link,name,description) FROM PROGRAM '. /etc/profile && \
+http_get https://html.com/attributes/ | \
+sed -E "s,<(thrive_headline|header)[^.>]+>([^<]+)</\1>,<div>\2</div>," | \
+xmllint --html --xpath //table - 2>/dev/null | \
+xml2csv - | \
+sed -E \
+       -e "s/”/\"/g" -e "s,^[^<]+(<[^>]+>)[^\t]+,\L\1," \
+       -e "s,^(<([^ ]+) ([^=>]+)),https://html.com/attributes/\2-\3/\t\1," \
+' WITH (format 'text', NULL ''); 
+COMMIT;
+
index b5fd3fd7bb2933696dddb1fdf4a434d8a4621bb7..17c993070b0b8ca4c6ba6ece2234f67c9deed1c4 100644 (file)
@@ -1,12 +1,12 @@
 DROP TABLE IF EXISTS html_tag;
 CREATE TABLE IF NOT EXISTS html_tag (
-  tag varchar(1000) PRIMARY KEY,
-  link varchar(300),
-  description varchar(5000)
+  name varchar(30) PRIMARY KEY,
+  description varchar(500),
+  link varchar(100)
 );
 BEGIN TRANSACTION;
 DELETE FROM html_tag;
-COPY html_tag (tag,link,description) FROM PROGRAM '. /etc/profile && html2txt https://html.com/tags/ \
+COPY html_tag (name,link,description) FROM PROGRAM '. /etc/profile && html2txt https://html.com/tags/ \
 | grep "^<" \
 | sed -E -e "s/ *HTML Tag *//" -e "s,^<([^>]+)>,\1\thttps://html.com/tags/\1/\t," \
 ' WITH (format 'text', NULL '');