>>69My guess into eir thought process is that ey wanted to make it general, at first, so that the project could be passed in as an argument, and also wanted to reuse one string for both the
system argument and the
fgets storage. I don't know why that was scrapped, though.
The whole thing kind of confuses me though, with using
curl instead of libcurl, that temporary file that's not cleaned up, that sloppy searching that will fail about 0.5% of the time (if the data is on a 2048-byte border), etc. Even accepting that exact method of searching, the whole damn thing can just be
how_much_funded() { curl "$*" 2>/dev/null | grep -o -e 'ed]">[^<]*' | cut -b 6-; }
in your shell, or (slightly better, though not quite as trivially shell-able)
#!/usr/bin/env perl
use Mojo::UserAgent;
print(Mojo::UserAgent->new->get(shift)->res->dom->find('data[itemprop="Project[pledged]"]')->first->all_text . "\n");
And bam! You can run those on anything you want and they don't have silly bugs. I fucking love C, but if you're going to use C, you should use it correctly, and the moment the real work is offloaded to
system+curl, the benefit for this particular task is lost, in my opinion. Unless perhaps the author was trying for an IOCCC-style thingy, in which case ey didn't go far enough to impress me, so I apologize for treating it solely as something intended to be useful. (In case you're reading and this
was, try reworking it so that the
for
loop is instead a recursive call to
main()
or something. I think I see how you can do it with just a little modification, and I'll be impressed. I promise.)