Skip to content

Instantly share code, notes, and snippets.

View aritraroy24's full-sized avatar
🤓
:):

Aritra Roy aritraroy24

🤓
:):
View GitHub Profile
@aritraroy24
aritraroy24 / contact_main.py
Created August 10, 2020 16:12
Sample code by Gmail API guide
from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/gmail.readonly']
@aritraroy24
aritraroy24 / contact_email_phone.py
Created August 10, 2020 18:48
Code to retrieve email and phone no from google contacts
from __future__ import print_function
import pickle
import os.path
from googleapiclient.discovery import build
from google_auth_oauthlib.flow import InstalledAppFlow
from google.auth.transport.requests import Request
import json
# If modifying these scopes, delete the file token.pickle.
SCOPES = ['https://www.googleapis.com/auth/contacts.readonly']
{
"$schema": "https://raw.githubusercontent.com/JanDeDobbeleer/oh-my-posh/main/themes/schema.json",
"blocks": [
{
"type": "prompt",
"alignment": "left",
"segments": [
{
"type": "os",
"style": "plain",
@aritraroy24
aritraroy24 / .env
Created June 4, 2021 13:57
.env File Example for Twitter Developer Credentials
Consumer_Key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Consumer_Secret_Key=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Access_Token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Access_Token_Secret=XXXXXXXXXXXXXXXXXXXXXXXXXXXXX
@aritraroy24
aritraroy24 / requirements.txt
Created June 4, 2021 14:01
Required modules for running the script online
tweepy
feedparser
decouple
bs4
@aritraroy24
aritraroy24 / CompChemNewsBot.py
Last active June 4, 2021 18:04
The main python script for running the bot
# importing modules
import feedparser
from bs4 import BeautifulSoup
import tweepy
import os
import logging
import datetime
# url for collecting news
url = "http://news.google.com/news?q=computational+chemistry&hl=en-US&sort=date&gl=US&num=100&output=rss"
@aritraroy24
aritraroy24 / url.py
Created June 4, 2021 14:17
URL for getting different news
url = "http://news.google.com/news?q=artificial+intelligence+in+chemistry&hl=en-US&sort=date&gl=US&num=100&output=rss"
@aritraroy24
aritraroy24 / parse.py
Last active June 4, 2021 14:28
parsing RSS feed to get text and url
class ParseFeed():
def __init__(self, url):
self.feed_url = url
def clean(self, html):
'''
Getting the text from html and doing some cleaning
'''
soup = BeautifulSoup(html)
@aritraroy24
aritraroy24 / authorise.py
Created June 4, 2021 14:31
authorise you to use Twitter as a developer
# Keys
CONSUMER_KEY = os.environ['Consumer_Key']
CONSUMER_SECRET_KEY = os.environ['Consumer_Secret_Key']
ACCESS_TOKEN = os.environ['Access_Token']
ACCESS_TOKEN_SECRET = os.environ['Access_Token_Secret']
# Authentication
auth = tweepy.OAuthHandler(CONSUMER_KEY, CONSUMER_SECRET_KEY)
auth.set_access_token(ACCESS_TOKEN, ACCESS_TOKEN_SECRET)
api = tweepy.API(auth)
@aritraroy24
aritraroy24 / tweet.py
Last active June 4, 2021 14:39
tweeting data after checking whether it is a repeat or not
def tweet(self, text_list, url_list):
'''
Posting the news in the twitter and logging the data (First news of the list will be posted: One can modify by using random function)
'''
# removing news already tweeted
file_name = "tweets.txt"
with open(file_name, "r") as file:
tweet_list = file.readlines()
tweet_list = [x.strip() for x in tweet_list]
for tweet in tweet_list: