Mostly working :) ~900mb to ~90mb

This commit is contained in:
Kai Hendry
2015-10-01 22:39:23 +08:00
parent b00e31138f
commit 574955249b
2 changed files with 6 additions and 7 deletions

View File

@@ -10,8 +10,8 @@ else
mkdir lock mkdir lock
fi fi
temp=$(mktemp "$1.XXXX") temp=$(mktemp)
temp2=$(mktemp "$1.XXXX") temp2=$(mktemp)
trap 'rm -vrf "${temp}" "${temp2}" lock' EXIT trap 'rm -vrf "${temp}" "${temp2}" lock' EXIT
@@ -35,8 +35,8 @@ then
test "$2" && since='&max_id='$(tail -n1 "$1.txt" | cut -d'|' -f1) # use max_id to get older tweets test "$2" && since='&max_id='$(tail -n1 "$1.txt" | cut -d'|' -f1) # use max_id to get older tweets
fi fi
while urlargs="screen_name=${1}&count=200&page=${page}${since}&include_rts=1&trim_user=0"; echo "$urlargs"; "$(dirname "$0")"/oauth.php "$urlargs" | while urlargs="screen_name=${1}&count=200&page=${page}${since}&include_rts=1&trim_user=0"; echo "$urlargs"; /srv/http/oauth.php "$urlargs" |
"$(dirname "$0")"/json-to-text.php > "$temp2"; test "$(wc -l < "$temp2")" -gt 0; /srv/http/json-to-text.php > "$temp2"; test "$(wc -l < "$temp2")" -gt 0;
do do
#cat temp2 #cat temp2
@@ -66,5 +66,4 @@ echo "$1" saved "$saved" tweets
test -L "$1.txt.gz" && rm "$1.txt.gz" test -L "$1.txt.gz" && rm "$1.txt.gz"
gzip -v "$1.txt" gzip -v "$1.txt"
ln -sfv "$1.txt.gz" tweets.txt.gz ln -sfv "$1.txt.gz" tweets.txt
stat -L tweets.txt 2>/dev/null || rm -f tweets.txt

View File

@@ -10,7 +10,7 @@ $QUERY=escapeshellarg($_GET['q']);
//fwrite($fp, $_GET['q'] . " : " . $QUERY . "\n"); //fwrite($fp, $_GET['q'] . " : " . $QUERY . "\n");
//fclose($fp); //fclose($fp);
exec("zgrep -Fhi $QUERY tweets.txt", $array); exec("gunzip -c tweets.txt | grep -Fhi $QUERY", $array);
$data = json_encode($array); $data = json_encode($array);
echo $_GET['jsoncallback'] . '(' . $data . ');'; echo $_GET['jsoncallback'] . '(' . $data . ');';
?> ?>