Code Monkey home page Code Monkey logo

twitter_python's Introduction

Twitter python

βœ… Setup

Requirements

python packages

πŸ‘‰ pip3 install urllib

πŸ‘‰ pip3 install requests

πŸ‘‰ pip3 install json

πŸ‘‰ pip3 install pprint This is to get data in an easy reading way.

πŸ‘‰ pip3 install tweepy Main Package to make tweets !

cron

πŸ‘‰ npm install cron See Downloading and installing Node.js and npm | npm Docs for more details about npm

TESTING integration πŸ‘‰ pip3 install textwrap

If you have some of those packages, download only necessary ones.

Steps

1️⃣ git clone https://github.com/GaloisField2718/Twitter_python

2️⃣ Get your Twitter API Keys on Twitter dev Portal. You will pass your twitter account in twitter dev account.

3️⃣ Add your keys in dogeaccountpy/config.py file.

4️⃣ Get your API-key in CoinMarketCap and put it in dogeaccountpy/prices.py (it's indicated in the code).

5️⃣ You can change messages in dogeaccountpy/messages.py.

6️⃣ You can make a first try with :

python3 tweets.py

7️⃣ Automation with cron : When you have cron you can launch on your computer a command like which provided in crontab.txt file.

🎯 Goal

1. πŸ™Œ Give the code which is running on Twitter

I created two twitter account : @Marketcryptopy and @dogeaccountpy which is running since few month and I want to share this code.

It's not strong coded and we can improve it in several differents ways but for now it works and that's cool 😎.

I will briefly details after what I used to get cryptocurrencies prices πŸ€‘, what config we need to use with tweepy and basic tweepy commands.

2. 🐚 Give some advice to use Twitter on python3 command-line

I also want to provide the basic shell commands I use to interact with @Marketcryptopy on my console. I'm trying to use this account only in command line and never interact through Twitter interface. Sometimes it's harder but it's fun to see it's possible.

ADDED COINMARKETCAP (CMC) LAST LISTINGS

πŸ§ͺ I tried to connect CMC API with latest Listings url, metadata url and tweepy to get information about new CMC listings. Especially get important data as website, description, social medias,...

㊷ Unfortunately, the textwrap python which I used seems to not produce convienent output :

Your Tweet text is too long. For more information on how Twitter determines text length see https://github.com/twitter/twitter-text.

I'm working hard on this issue to produce soon πŸ”œ a working bot for this job.

πŸ”© Tools

1. πŸ’° Get prices

To get prices I use 2 differents API :

πŸ‘‰ MarketCryptoPy : CoinMarketCap-API.

πŸ“œ The unofficial documentation : python-binance but it's quite hard to onboard through this. There is an incredible Youtube Channel @cryptorobotfr, they are french but you can translate the video and their code is in english so don't worry 😁.

πŸ“Ί One very good video to begin with python-binance package [TUTO FR] CrΓ©er son PROPRE BOT DE TRADING CRYPTO facilement en Python ! and the associated github repo create personnal trading bot.

πŸ‘‰ DogeAccountPy : python-binance.

πŸ“œ Documentation : CoinMarketCap API Documentation

πŸ“Ί Youtube channels can help you to onboard with CoinMarketCap API.

πŸ” Looking for optimization Le Design Pattern Contre-Intuitif le plus utilisΓ© par les DΓ©veloppeurs Professionnels.--

2. 🐣 Tweepy

To onboard with this package you definitely should see this video πŸ“Ί How to use the Twitter API v2 in Python using Tweepy. All my Tweepy code is based on this video !

3. πŸ€– Automation

The automation is made with cron - npm. It's an automation tool in command line that you can install easily with : npm install cron.

After you install it you can check some use on crontab.guru.

I provide a crontab file without extension which can be open by every text editor. It's a basic syntax but this file provide a solution when your shell doesn't find the good python compiler.

This automation actually runs on AWS EC2 Instance with a free account but I think it will be removed soon because I don't want to pay!

Still in french you can find a good detail about how to deploy an AWS free instance [Tuto FR] HΓ©berger votre BOT DE TRADING crypto GRATUITEMENT en Python sur un serveur avec FTX.

Structure

1. PricesByCMC

πŸ‘‰ config.py : which stores every twitter access keys.

πŸ‘‰ prices.py : which ask prices at CoinMarketCap and provide some functions to simplify messaging and accessing data. There is also a function metsLesVirgules which makes the same thing as "{:=,}".format(value) but I didn't know so I hardcoded this function and I let here.

πŸ‘‰ messages.py : uses every functions in prices to provide 3 messages.

πŸ‘‰ tweets.py : the last one obviously... to TWEET PRICES πŸ€‘ ‼️

πŸ‘‰ crontab : the file where the command is stored to automate post.

2. PricesByBinance

This uses python-binance package, and contains only two files :

πŸ‘‰ Twitter.py : it's my first file and contains Binance prices call, messages and tweeting via tweepy.

πŸ‘‰ config.py : still a config file to run all of this.

3. NewListingOnCMC

πŸ‘‰ listings_cmc.py : make the call to get latest CMC listings.

πŸ‘‰ metadata_listings.py : provide metadata related to latest listings taking from listings_cmc.py.

πŸ‘‰ tweets_wrapper.py : a simple file which contains one function : tweets_wrapper.

I think problems raised from tweets_wrapper or tweets. If someone is available to chat about this it will be a pleasure πŸ˜„

πŸ‘‰ tweets.py : obviously posting file, but also some textual operations to improve each threads.

twitter_python's People

Contributors

galoisfield2718 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.