/*
experimental
usage: [host=example.com] yy044 [ar]
*/
int fileno (FILE *);
int x,y,absolute,relative,omit,proto;
int setenv (const char *, const char *, int);
int fprintf(FILE *__restrict, const char *__restrict, ...);
size_t strlen (const char *);
http https://|http://
js javascript:
%option nounput noinput noyywrap
%%
href=[^{http}{js}\"'][^\"'\40>]+ puts("yy044");
href=[\"'][^{http}{js}][^\"'\40>]+ {
omit=0;proto=0;
if(yytext[6]==46)omit++;
if(yytext[7]==47)proto++;
if(!omit)if(relative)
{
y=0;for(x=6;x\43\42\47|\r\n]+ {
if(absolute)
if(yyleng>8)
{
y=0;for(x=0;x\43\42\47|\r\n]+ {
if(absolute)
if(yyleng>7)
{
y=0;for(x=0;xExtract URLs Relative and/or Absolute yy044
1–2 of 2 posts
Re: Extract URLs Relative and/or Absolute yy044
#2Normally I use yy030 but I have been experimenting with this instead.
Seems to be slightly faster and smaller than similar programs from html-xml-utils.
https://www.w3.org/Tools/HTML-XML-utils/man1/
Compile:
links -no-connect -dump https://news.ycombinator.com/item?id=38727772 \
|sed '1,4d;77,$d;s/[ ]\{6\}//' \
|flex -8Cem;cc -O3 -std=c89 -W -Wall -pipe lex.yy.c -static -o yy044
strip -s yy044
Example usage: # NB. not a real cookie
curl -H "cookie=user=santa&K7RGzmUtAoKv9OIRMfQ9bfwYpiDEuypp" -siA "" \
https://news.ycombinator.com \
|host=news.ycombinator.com/ yy044 r \
|sed -n 's/&/\&/g;/vote/p'