Last active
October 13, 2017 10:50
-
-
Save ks7000/91c2c29019c45cfc28dc71797fe97ec1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
#!/usr/bin/python | |
# coding=utf-8 | |
# | |
# Copyright [2017] [Jimmy Olano, Twitter @ks7000] | |
# | |
# Licensed under the Apache License, Version 2.0 (the "License"); | |
# you may not use this file except in compliance with the License. | |
# You may obtain a copy of the License at | |
# | |
# http://www.apache.org/licenses/LICENSE-2.0 | |
# | |
# Unless required by applicable law or agreed to in writing, software | |
# distributed under the License is distributed on an "AS IS" BASIS, | |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
# See the License for the specific language governing permissions and | |
# limitations under the License. | |
import twitter | |
TOKEN="/* ¡TUS CREDENCIALES! */" | |
TOKEN_KEY="/* Vuestros valores */" | |
CON_SEC="/* tus valores */" | |
CON_SEC_KEY="/* tu mismo te identificas, cambiar esto */" | |
import re | |
import time | |
import binascii | |
def texto_de_bits(bits, encoding='utf-8', errors='ignore'): | |
n = int(bits, 2) | |
return int2bytes(n).decode(encoding, errors) | |
def int2bytes(i): | |
hex_string = '%x' % i | |
n = len(hex_string) | |
return binascii.unhexlify(hex_string.zfill(n + (n & 1))) | |
my_auth = twitter.OAuth(TOKEN,TOKEN_KEY,CON_SEC,CON_SEC_KEY) | |
twit = twitter.Twitter(auth=my_auth) | |
#https://twitter.com/VodafoneTV_es/status/918771809633423360 | |
emisor = 'VodafoneTV_es' | |
tl=twit.statuses.user_timeline(screen_name=emisor) | |
for status in tl: | |
tuit=status["text"] | |
palabras=tuit.split() | |
trad = '' | |
publicar = 0 | |
for palabra in palabras: | |
letra = palabra[0] | |
if letra == '@': | |
trad = trad + palabra + " " | |
if letra == '0' or letra == '1': | |
cad = re.findall(r'\d+', palabra) | |
x = '' | |
for w in cad: | |
x = x + w | |
if len(x) == 8: | |
publicar = 1 | |
trad = trad + texto_de_bits(x) | |
trad = str(status['id']) + " " + emisor + " " + trad | |
if publicar == 1: | |
print trad | |
twit.statuses.update(status=trad) | |
time.sleep(7) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment