Here is a screenshot of the Twitter Bot:
What is different this time, is that I wish to use AWS Lambda as the backend. I want to know what is required and what the workflow was. I wont repeat the steps Joel listed out in his tutorial, just some of the things I found out:
1. Seems that AWS Lambda wants the main file to be lambda_function.py and the main function to be lambda_handler(event, context).
2. The scheduling trigger is now "CloudWatch Events - Schedule" instead of just schedule.
3. I learned this from a friend that to always immediately put the credential file in .gitignore to avoid accidentally checking it in on GitHub.
echou$ cat .gitignore
*.pyc
credentials.json
I am now the proud owner of a Twitter Bot that searches for Cisco layoff news and retweet them. On this date of Aug. 19, 2016 that was the big news of the week.
https://twitter.com/Network4_Nerds
echou$
Here is what my code ended up as:
from __future__ import print_function
from twython import Twython
from twython.exceptions import TwythonError
import re
import json, pprint
with open('credentials.json') as f:
credentials = json.loads(f.read())
client = Twython(credentials["consumer_key"],
credentials["consumer_secret"],
credentials["access_token_key"],
credentials["access_token_secret"])
query = "cisco layoffs -filters:retweets"
rgx = r"cisco"
def lambda_handler(event, context):
results = client.search(q=query)
for tweet in results["statuses"]:
text = tweet["text"]
# re.search matches anywhere in the string; re.I means case-insensitive
if re.search(rgx, text, re.I):
print(tweet["text"])
# client.retweet will raise an error if we try to retweet a tweet
# that we've already retweeted. to avoid having to keep track, we
# just use a try/except block
try:
client.retweet(id=tweet["id"])
except TwythonError as e:
print(e)
results = client.search(q=query)
pprint.pprint(results)
Happy Coding!
That is very interesting; you are a very skilled blogger. I have shared your website in my social networks! A very nice guide. I will definitely follow these tips. Thank you for sharing such detailed article.
ReplyDeleteAws Online Training
Hi Eric,
DeleteNice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long.
I am a beginner in programming,started learning python a few days ago.When I was doing exercise,found a problem that I couldn't solve by myself.Could anyone help me about it?Thank you very much.
My python version is 3.6.3
the codes:
Python Code: (Double-click to select all)
1
2
3
4 name = ["aa", "bb", "cc", "dd"]
for zzz in (name):
name.remove(zzz)
print(name)
I wanted to delete or remove all values in the list,but the results always contain the values on the even places (like "bb" and "dd").
However,when I execute codes below:
Python Code: (Double-click to select all)
1
2
3 name = ["aa","bb","cc","dd"]
for zzz in (name):
print("hello, " + zzz)
I can get the results I want, printing every string with all the names in the list.
Is it because this function cannot use with remove function?
PEP 8 provides coding conventions for the Python code. It describes rules to adhere while coding in Python. This helps in better readability of code and thereby better understanding and easy maintainability. It covers from code indentation, amount of space to use for indentation, spaces v/s tabs for indentation, commenting, blank lines, maximum line length, way of importing files, etc.
It was cool to see your article pop up in my google search for the process yesterday. Great Guide.
Keep up the good work!
Ciao,
Hima
Updating ourselves to the latest technology is the good idea to live in this modern IT world. Reading articles like your blog this will make an encouraging power within me. Thanks for sharing such an informative content. AWS Training in Bangalore | Big Data Hadoop Training in Bangalore
ReplyDeleteThis sites is known about the latest using programming languages and other supporting stuffs on the existing IT skills companies.
ReplyDeleteyou provide a very good information that is very useful for modern IT world. I gather lot of articles but this very nice one to read,They gave lot of new ideas for me.Thanks for sharing this valuable information.
ReplyDeletePython Online Training
Thanks for sharing this unique and informative post. This blog which provided me the required information. Software Testing Training in Chennai | Java Training in Chennai
ReplyDeleteThanks for sharing such a wonderful blog tableau training in bangalore
ReplyDeleteverygood blog helpful to everyone digital marketing courses in bangalore
ReplyDeleteexcellent blog hadoop training in bangalore
ReplyDeleteIt’s too informative blog and I am getting conglomerations of info’s about Python certification. Thanks for sharing,
ReplyDeletePython Training in Marathahalli
Java Training in Marathahalli
Nice blog AWS training in bangalore
ReplyDeleteHadoop training in bangalore
Tableau training in bangalore
PHP training in bangalore
Android training in bangalore
Digital marketing training in bangalore
useful blog iot training in bangalore
ReplyDeleteDevops Training in Bangalore
iteanz
ReplyDeletemachine learning training in bangalore
Nice Block On Network Automation
ReplyDeleteDevops Training
nice blog
ReplyDeletepython training in bangalore
Very nice post. Awesome article... Really helpful
ReplyDeleteGreat information. Thank you for sharing
ReplyDeleteThanks for sharing valuable information on Devops Online Training Hyderabad
ReplyDeletevery nice interview questions
ReplyDeletevlsi interview questions
extjs interview questions
laravel interview questions
sap bi/bw interview questions
pcb interview questions
unix shell scripting interview questions
really awesome blog
ReplyDeletehr interview questions
hibernate interview questions
selenium interview questions
c interview questions
c++ interview questions
linux interview questions
spring mvc interview questions
machine learning online training
servlet interview questions thanks for sharing
aws migration services
ReplyDeleteaws server migration service
aws migration services providers
Nice blog
ReplyDeletesap partner companies in bangalore
sap implementation companies in bangalore
sap partners in india
aws staffing
jquery interview questions
sql interview questions
I got nice blog
ReplyDeleteangular4 interview questions
python interview questions
artificial intelligence interview questions
python online training
artificial intelligence online training
Thank you for sharing this type of interview questions
ReplyDeleteIot Online Training
Itil Interview Questions
Salesforce Interview Questions
Msbi Interview questions
Salesforce Interview Questions
C Interview Questions
aws partners in bangalore
aws partners in india
aws service providers in india
aws service providers
Nice Blog
ReplyDeletesap partner companies in bangalore
sap implementation companies in bangalore
sap partners in india
aws staffing
Nice information
ReplyDeleteBest Online course
Free Online course
Online Training Course
aws,python,hadoop Online Training
aws,python,hadoop,Devops, data science,interview questions
Iteanz Technologies
I feel really happy to have seen your webpage and look forward to so
ReplyDeletemany more entertaining times reading here. Thanks once more for all
the details.
AWS Training in Bangalore
AWS Training in Bangalore
At that point I scanned for website architecture, site improvement, and pay per click Buy twitter followers
ReplyDeleteIt has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.
ReplyDeleteData Science Training in Bangalore
DataScience Training in Chennai
Informative post about hadoop, i am looking forward for realtime hadoop online training institute.
ReplyDeleteGreat article. May be create a short video/GIF about the working of the application. It will be very useful to see the working of the app.
ReplyDeleteAshwathi,
Facilitator,
Kamal Technologies - Best React JS, Angular JS, Node JS training institute in Chennai
This blog is very helpful for beginners and experts also, thanks for sharing it. Keep share content on MSBI Online Training Bangalore
ReplyDeletemany people come and go but i don't think that anyone can replace him https://twitter.com/darrenwinters01 follow this man for the best ideas about business..!!
ReplyDeletegreat
ReplyDeleteWhoa! I’m enjoying the template/theme of this website. It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance” between superb usability and visual appeal. I must say you’ve done a very good job with this.
ReplyDeleteAWS Training in Bangalore|
I simply wanted to thank you so much again. I am not sure the things that I might have gone through without the type of hints revealed by you regarding that situation.
ReplyDeleteamazon-web-services-training-institute-in-chennai
Best Hadoop Training Institute In chennai
I believe there are many more pleasurable opportunities ahead for individuals that looked at your site.
ReplyDeleteSelenium Training in chennai