2 ms·
/*````````crossref json`````````*/ <M25>\"next-cursor\":\"[^\"]+ { for(z=15;z<yyleng;z++) { if(yytext[z]==61)dprintf(3,"%s","%3D"); if(y
by 1vuio0pswjnm7 3y ago
/*````````crossref json`````````*/
<M25>\"next-cursor\":\"[^\"]+ {
for(z=15;z<yyleng;z++)
{
if(yytext[z]==61)dprintf(3,"%s","%3D");
if(yytext[z]!=61)dprintf(3,"%c",yytext[z]);
}
putc(10,stderr);
}
<M25>\"DOI\":\"[^\"]+ {
y=0;for(x=7;x<yyleng;x++)if(y<255)if(yytext[x]!=92)
{yytext[y]=yytext[x];y++;};urllen=y;
setenv("url",yytext,1);
}
<M25>\"created\":\{\"date-parts\":\[\[[0-9,]+\]\],\"date-time\":\"[0-9TZ:-]{20}+\",\"timestamp\":[^}]{10} {
y=0;for(x=yyleng-10;x<yyleng;x++){yytext[y]=yytext[x];y++;}
setenv("date",yytext,1);
datelen=y;
}
<M25>\"title\":\[\" {
CDp8iULPuCinsert(25);
fwrite("https://dx.doi.org/",1,19,yyout);
fwrite(getenv("url"),1,urllen,yyout);
fwrite("','",1,3,yyout);
jmp M25_DESC;
}
<M25_DESC>\" fwrite("');\n",1,4,yyout);jmp M25;
<M25_DESC>\\u200[35] putc(34,yyout);
<M25_DESC>\\u201[cd] putc(34,yyout);
<M25_DESC>\\u201[89] putc(39,yyout);putc(39,yyout);
<M25_DESC>\\u201[340] putc(45,yyout);
<M25_DESC>\\u2026 fwrite("...",1,3,yyout);
<M25_DESC>\\u00e[124] putc(97,yyout);
<M25_DESC>\<[^>]+\>
<M25_DESC>\x27 putc(39,yyout);putc(39,yyout);
<M25_DESC>[^\"\n] putc(yytext[0],yyout);
/*````````crossref html`````````*/
<M25>class=\"lead\">\n[ ]{6}[^\n]+ {
y=0;for(x=20;x<yyleng;x++)if(y<255)
{
if(yytext[x]==60){x++;z++;};
if(yytext[x]==62){x++;z--;};
if(!z)desc[y]=yytext[x];
if(!z)y++;
}
desclen=y;
}
<M25>javascript:showCiteBox\(\"[^\"]+ {
CDp8iULPuCinsert(25);
fwrite("https://dx.doi.org/",1,19,yyout);
for(x=25;x<yyleng;x++)putc(yytext[x],yyout);
fwrite("','",1,3,yyout);
for(x=0;x<desclen;x++)
{
if(desc[x]==39)putc(39,yyout);
putc(desc[x],yyout);
}
fwrite("');\n",1,4,yyout);
}
To test:
#!/bin/sh
test $1||exec sed -n '/^ *;;/p' ${0##*/};
read x;
case $1 in :)
;;25a) # crossref www
shift
{
yy084 25 "$x page=${1-1}"
x=$(echo "$x"|sed 's/ /+/g;s/++/+/g')
curl -k -si40 \
-A "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.79 Safari/537.36" \
"https://search.crossref.org/search/works?q=$x&from_ui=yes&page=${1-1}"
} |sed w025.htm
;;25b) # crossref api from www
test -f 05.htm||exec echo run ${0##*/} 25a first
shift
{
yy084 25 "$x page=${1-1}";
x=$(echo "$x"|sed 's/ /+/g;s/++/+/g')
sed -n '/<a href=\"https:\/\/api.crossref.org\/works/{
s/<a href=\"//;s/\">//;s/ */url=/p;}' 025.htm |curl -k -si40A "" -K/dev/stdin
# faster, more efficient using HTTP/1.1 pipelining, e.g.,
# yy030 < 025.htm|sed -n '/g\/works/p'|yy025|nc -vvn 127.7 80
}
;;25c) # crossref api
shift
yy084 25 "$x cursor=${1-*}";
if test $# -eq 0;then
curl -si40A "" "https://api.crossref.org/works?query=$x&rows=1000&select=DOI,created,title&cursor=*"
fi
# yy084 < 1.json 3>1.cursor|sqlite3 test.db
if test $# -eq 1;then
read y < $1
y=${y##*\"}
curl -si40A "" "https://api.crossref.org/works?cursor=$y"
else exec echo usage: ${0##*/} 25c 1.cursor
fi
esac
echo research|1.sh 25a > 25a.serp
echo research|1.sh 25b > 25b.serp
echo research|1.sh 25c > 25c.serp
cat [0-9]*[a-c]*.serp|yy084|sqlite3 test.db