zalandotxtbrand

In [ ]:
zalando text brand

analzye text from zalando brands
In [152]:
import getpass
import requests
import nltk
import random
import arrow
import json
In [65]:
curtim = arrow.now()
In [51]:
myusr = getpass.getuser()
In [150]:
with open('/home/{}/brand.txt'.format(myusr), 'r') as branope:
    brard = (branope.read())
    #print(brard)
In [89]:
nlwr = nltk.word_tokenize(brard)
In [90]:
nlwr.sort()
In [91]:
dalis = list()
In [149]:
for sen in set(nlwr):
    if len(sen) > 8:
        #print(sen)
        dalis.append(sen)
In [93]:
len(dalis)
Out[93]:
241
In [95]:
randa = random.sample(dalis, 5)
In [148]:
try:
    for ran in dalis:
        print(ran)
        reqfo = requests.get('http://api.giphy.com/v1/gifs/search?q={}&api_key=dc6zaTOxFJmzC'.format(ran))
        #print(reqfo.json())

        rej = reqfo.json()

        rez = rej['data'][0]['images']['original']['url']
        print(rez)

        with open ('/home/{}/za/posts/{}.md'.format(myusr, ran), 'w') as ranmd:
        #oppost.write('![{}'.format())
            ranmd.write(('![' + ran + '](' + rez + ')\n\n' + ran))

        with open ('/home/{}/za/posts/{}.meta'.format(myusr, ran), 'w') as ranmeta:
        #opmetat.write("{}".format(str(curtim))
            ranmeta.write('.. title: {}\n.. slug: {}\n.. date: {}\n.. tags: \n.. link:\n.. description:\n.. type: text'.format(ran, ran, curtim))
            
#except IndexError:
except IndexError:
    pass
adjustable
http://media0.giphy.com/media/f0dlKKJMHGlJC/giphy.gif
jewellery
http://media0.giphy.com/media/S5NF19FUYNEic/giphy.gif
Understated
http://media2.giphy.com/media/QV5sMr0LaS89y/giphy.gif
compromise
http://media0.giphy.com/media/l0HlTTvEWSj3C3s3K/giphy.gif
compliment
https://media4.giphy.com/media/l3V0nzIFlQPh5LXYk/giphy.gif
intimates
http://media4.giphy.com/media/14nwIfYOFs73xe/giphy.gif
clothingare
In [131]:
with open('/home/{}/zalandobrand.json'.format(myusr), 'r') as zalajs:
    zalabr = (zalajs.read())
In [133]:
jsza = json.loads(zalabr)
In [153]:
for js in jsza.values():
    #print(js)
    #print(js['slug'])
    
    #print(js['header'])
    #print(js['title'])
    #print(js['logo'])
    
    #print(js['banner'])
    
    with open ('/home/{}/za/posts/{}.md'.format(myusr, (js['slug'])), 'w') as ranmd:
        #oppost.write('![{}'.format())
        ranmd.write(('![' + (js['slug']) + '](' + (js['banner']) + ')\n\n' + js['header'] + '\n\n' + js['description']))

    with open ('/home/{}/za/posts/{}.meta'.format(myusr, js['slug']), 'w') as ranmeta:
        #opmetat.write("{}".format(str(curtim))
        ranmeta.write('.. title: {}\n.. slug: {}\n.. date: {}\n.. tags: \n.. link:\n.. description:\n.. type: text'.format(js['slug'], js['slug'], curtim))
          
    
    
In [ ]:
 

Comments

Comments powered by Disqus