Last active
August 29, 2015 14:03
-
-
Save sirhc/cb7475f066ba60a9d34c to your computer and use it in GitHub Desktop.
Screen scrape a tweet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash -eu | |
curl -sL "$1" \ | |
| perl -l -ne 'm{"text/xml\+oembed"} && m{title=".*? on Twitter: "([^"]*)""} && print $1' \ | |
| perl -pe 's{&#(\d+);}{chr($1)}ge; s{"}{"}g;' \ | |
| perl -pe 's{(https?://t.co/\w+)}{ `curl -s -D- $1 | awk '\''/^location:/{print \$2}'\'' | tr -d "\r\n"` }ge' \ | |
| sed -e :a -e '/^\n*$/{$d;N;};/\n$/ba' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!perl | |
use strict; | |
use warnings; | |
use Test::More; | |
use Test::Command; | |
my $cmd = './tweet.sh'; | |
stdout_is_eq( | |
[ $cmd, 'https://twitter.com/JordanPeele/status/484153672369061888' ], | |
( "The Shining\n" . | |
"๐ช๐๐ป๐ฃ\n" . | |
"๐๐ฆ๐\n" . | |
"๐๐ฒ\n" . | |
"๐ฆ๐๐พ\n" . | |
"๐๐ฒ๐ช\n" . | |
"๐ฉ๐ฆ๐๐ก\n" . | |
"๐๐ฒ๐ญ\n" . | |
"๐ฆ๐ท๐ฑ\n" . | |
"โ๏ธ๐\n" . | |
"๐๐บ\n" . | |
"๐ฆ๐ช๐๐๐ต\n" . | |
"๐๐ถ๐๐ถ๐ฆ๐ท๐ฑ\n" . | |
"๐ฆ๐ฝ๐ด\n" . | |
"๐โ๏ธ\n" . | |
"๐ฉ๐๐๐๐๐๐๐ฑ\n" . | |
"๐ฉ๐ฅ๐ฆ๐ค\n" . | |
"๐ฉ๐๐ฆ\n" . | |
"๐ด๐๐ฆ\n" . | |
"๐ฆ๐จ๐ช๐ช๐ฉ\n" . | |
"๐๐\n" . | |
"๐ฆ๐จ๐๐\n" . | |
"๐ฉ๐บ๐จ\n" . | |
"๐ฉ๐๐๐\n" . | |
"๐ฉ๐ช๐๐๐\n" . | |
"โ๏ธ๐ณ๐๐ณโ๏ธ\n" . | |
"๐จ๐ฆโ๏ธ\n" . | |
"๐ฆ\n" | |
), | |
'https://twitter.com/JordanPeele/status/484153672369061888 (Emoji)', | |
); | |
stdout_is_eq( | |
[ $cmd, 'https://twitter.com/hitsuji44/status/482031745961717762' ], | |
"ๅพใ ใซ้ใพใฃใฆใใไปฎ็ฝฎใๅ ดใใใใฏใไบไบบๅญไพใๆใคๅไบบๅฎ ใฎ็่ฃใซๅญๅจใใใๆบๆฏใซใชใใฐใ็ซๆดพใชใใใในใใใใจใชใใฎใ ใใใ่ฆใฆใใใ ใใงใ้ฆใฎ่ ซใใ็ใฟๅบใใฆใใใ(-_-) http://twitter.com/hitsuji44/status/482031745961717762/photo/1\n", | |
'https://twitter.com/hitsuji44/status/482031745961717762 (Japanese)', | |
); | |
stdout_is_eq( | |
[ $cmd, 'https://twitter.com/jaqque/status/484759521420922880' ], | |
( "Multiball!\n" . | |
"Multiline!\n" . | |
"https://www.youtube.com/watch?v=iq1d07gYl8o\n" . | |
"(This is me testing Prospero)\n" | |
), | |
'https://twitter.com/jaqque/status/484759521420922880 (Multi ball^Wline)', | |
); | |
stdout_is_eq( | |
[ $cmd, 'https://twitter.com/paleofuture/status/593496008232800256' ], | |
qq("A Doctor Oz Investigation: What Happens When You Die?"\n), | |
'https://twitter.com/paleofuture/status/593496008232800256 (Reply)', | |
); | |
done_testing; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Emoji: https://twitter.com/JordanPeele/status/484153672369061888
Japanese: https://twitter.com/hitsuji44/status/482031745961717762
Multi ball^Wline: https://twitter.com/jaqque/status/484759521420922880