From: Nicolas Boisselier Date: Thu, 21 Jun 2018 22:33:36 +0000 (+0100) Subject: lib/postgres/html_attribute.sql X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=d3f35f84fb378e9d5af2d541b9298b67144ee634;p=nb.git lib/postgres/html_attribute.sql --- diff --git a/lib/postgres/html_attribute.sql b/lib/postgres/html_attribute.sql new file mode 100644 index 00000000..aabb2185 --- /dev/null +++ b/lib/postgres/html_attribute.sql @@ -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)[^.>]+>([^<]+),
\2
," | \ +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; + diff --git a/lib/postgres/html_tag.sql b/lib/postgres/html_tag.sql index b5fd3fd7..17c99307 100644 --- a/lib/postgres/html_tag.sql +++ b/lib/postgres/html_tag.sql @@ -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 '');