示例#1
0
def get_week(napr, kurs):

    k = 0
    k = k + kurs
    if napr == "ГЕОЛ":
        k = 4 + kurs
    elif napr == "ХИМФ":
        k = 8 + kurs
    if teleg[k] == 0:
        a = ''
        for i in range(0, 7):
            a = a + "\n" + get_day(napr, kurs, i + 1)
        a = a.replace("*", "")
        a = a.replace("ПМИИ", "")
        a = a.replace("ГЕОЛ", "")
        a = a.replace("ХФММ", "")
        a = a.replace("- ", "")
        a += '\n<strong>Удачной учёбы! by \n <a href="t.me/MGURASP_Bot" target="_blank">t.me/MGURASP_Bot</a>'

        try:
            t = Telegraph()
            t.createAccount("PythonTelegraphAPI")
            title = napr + ' ' + str(kurs) + ' - Расписание'
            page = t.createPage(title, html_content=a)
            teleg[k] = 'http://telegra.ph/{}'.format(page['path'])
            return teleg[k]
        except:
            print("Error adding to telegra.ph")
            return 'В связи с блокировкой телеграмм произошла ошибка'
    else:
        return teleg[k]
示例#2
0
def telegraph(artist, song, lyrics):
    t = Telegraph()
    t.createAccount("PythonTelegraphAPI")
    spam = '\n<strong>lyrics from <a href="http://genius.com/" target="_blank">genius.com</a>\n' \
           'presented by <a href="http://t.me/ReallyLyricsBot" target="_blank">t.me/ReallyLyricsBot</a></strong>'
    title = song + ' by ' + artist
    try:
        page = t.createPage(title, html_content=lyrics + spam, author_name=artist)
        return 'http://telegra.ph/{}'.format(page['path'])
    except:
        print("Error adding to telegra.ph")
示例#3
0
def make_telegraf_page(images):
    telegraph = Telegraph()

    telegraph.createAccount("PythonTelegraphAPI")
    # page = telegraph.createPage("Hello world!", html_content="<b>Welcome, TelegraphAPI!</b>")

    tags_list = []
    for i in images:
        tags_list.append("<img src='{}'/>".format(i))

    content = '\n'.join(tags_list)
    page = telegraph.createPage("Недвижимость Харьков", html_content=content)

    return 'http://telegra.ph/{}'.format(page['path'])
示例#4
0
def get_last_day(napr, kurs, dn):
    days = [
        "ПОНЕДЕЛЬНИК", "ВТОРНИК", "СРЕДА", "ЧЕТВЕРГ", "ПЯТНИЦА", "СУББОТА",
        "ВОСКРЕСЕНЬЕ"
    ]
    k = 0
    k = k + kurs
    if napr == "ГЕОЛ":
        k = 4 + kurs
    elif napr == "ХИМФ":
        k = 8 + kurs
    if teleg1[k] == 0:
        a = ''
        d = datetime.datetime.now()
        if d.hour < 12:
            dnn = 8
            ms = 0
        else:
            dnn = 7
            ms = 1
        for i in range(dn, dnn):
            a = a + "\n" + get_day(napr, kurs, i + ms)
        a = a.replace("*", "")
        a = a.replace("ПМИИ", "")
        a = a.replace("ГЕОЛ", "")
        a = a.replace("ХФММ", "")
        a = a.replace("- ", "")

        try:

            t = Telegraph()

            t.createAccount("PythonTelegraphAPI")
            title = napr + ' ' + str(kurs) + ' - Расписание'
            a += '\n<strong>Удачной учёбы! by \n <a href="t.me/MGURASP_Bot" target="_blank">t.me/MGURASP_Bot</a>'
            page = t.createPage(title, html_content=a)
            teleg1[k] = 'http://telegra.ph/{}'.format(page['path'])
            return teleg1[k]
        except:
            print("Error adding to telegra.ph")
            return 'В связи с блокировкой телеграмм произошла ошибка\n' + a
    else:
        return teleg1[k]
TOKEN_TELEGRAM = '335844830:AAFHubomXjxZD4DlVsW9ql5zHLt9f1Cutyo'
TOKEN_TELEGRAM_2 = '290483632:AAHcBwHtGAoM_GuIq3R32J9mOrX75FyMZE8'

API_GOOGLE_SHORTNER = 'AIzaSyDf6meD_lupaK7uUUha3s5P6LkCG6588m4'
MERCURY_WEB_PARSER = 'nGc0ya2J7z2aalFrGa8Gx3Q1o8grGFsn3cz58EJy'

MY_READING_WORDS_PER_MINUTE = 235  #http://www.readingsoft.com/

bot = telegram.Bot(TOKEN_TELEGRAM)
bot2 = telegram.Bot(TOKEN_TELEGRAM_2)
shortener = Shortener('Google', api_key=API_GOOGLE_SHORTNER)
chat_id = 31923577

url = 'https://hacker-news.firebaseio.com/v0/item/'
url2 = '.json?print=pretty'
telegraph = Telegraph()
telegraph.createAccount("PythonTelegraphAPI")

parser = MercuryParser(api_key=MERCURY_WEB_PARSER)

try:
    update_id = bot.getUpdates()[0].update_id
except IndexError:
    update_id = None


def getTimeReadingString(words):
    lung = words
    minutes = lung / MY_READING_WORDS_PER_MINUTE
    if minutes == 0:
        return "\n" + str(lung) + " words. ~1 min."
示例#6
0
import os
import threading
import traceback
#import postgresql
import urllib.request
import requests
from boto.s3.connection import S3Connection

#https://devcenter.heroku.com/articles/config-vars#using-foreman-and-heroku-config

TOKEN_ALERT = os.environ['TOKEN_ALERT']
TOKEN_TELEGRAM = os.environ['TOKEN_TELEGRAM']
TELEGRAPH_ACCOUNT = os.environ['TELEGRAPH_ACCOUNT']


telegraph = Telegraph()
telegraph.createAccount(TELEGRAPH_ACCOUNT)
 
MY_ITALIAN_READING_PER_MINUTE = 235
bot = telegram.Bot(TOKEN_TELEGRAM)
chat_id_List = []
allUrl = []
allRssFeed = []

try:
    update_id = bot.getUpdates()[0].update_id
except IndexError:
    update_id = None

def init_DB():
	conn = sqlite3.connect( DATABASE_NAME ) 
import feedparser
from telegraphapi import Telegraph
import telegram
from telegram import *
import time
import os
import re
import sqlite3
import schedule
import datetime
from telegram.error import NetworkError, Unauthorized
import threading 
from feedfinder2 import find_feeds


telegraph = Telegraph()
telegraph.createAccount("PythonTelegraphAPI")
TOKEN_TELEGRAM = '282010348:AAHWydTbEOODrsZIzJMYFvmuVyVSK6G1b_Q' 
DATABASE_NAME = 'RSS.db'
bot = telegram.Bot(TOKEN_TELEGRAM)
chat_id_List = []


try:
    update_id = bot.getUpdates()[0].update_id
except IndexError:
    update_id = None

def init_DB():
	conn = sqlite3.connect( DATABASE_NAME ) 
	cursor = conn.cursor()
示例#8
0
pics = pics[pics.find("[['"):]
links = ast.literal_eval("{1:" + pics[:pics.find("{") - 14] + ']' + "}")[1]
picURL = ''
for link in links:
    picURL = picURL + "<img src='" + "https:" + link[0] + link[2][:link[2].find(
        "?"
    )] + "'><figcaption></figcaption>"  # ссылка на картинку в <img src='PICURL'>
tag_list = ''
print(picURL)
for i in items.find("div", class_="tile-info").contents:
    try:
        tag_list = tag_list + " #" + i.contents[0]
    except:
        pass

print(items.contents[1].contents[5].contents[9].attrs['title'])
print(items.contents[1].contents[5].contents[7].contents[1].attrs['title'])
print(tag_list)
telegraph = Telegraph()

telegraph.createAccount("PythonTelegraphAPI")
page = telegraph.createPage(
    items.contents[1].contents[5].contents[7].contents[1].attrs['title'],
    html_content="<b>" +
    items.contents[1].contents[5].contents[9].attrs['title'] + "</b><h4>" +
    tag_list + "</h4>" + picURL,
    author_name=author_name,
    author_url=author_url)

print('http://telegra.ph/{}'.format(page['path']))
# -*- coding: utf-8 -*-
from telegraphapi import Telegraph
import telegram
from telegram import *
from newspaper import Article

telegraph = Telegraph()
telegraph.createAccount("PythonTelegraphAPI")
TOKEN_TELEGRAM = '358045589:AAH-Bzm42xxEAeGZRLwDPsmQTSNZMKqBBrU' #DeutschFormel1Bot

bot = telegram.Bot(TOKEN_TELEGRAM)

url = 'http://www.sport1.de/motorsport/formel1/2017/03/formel-1-pressestimmen-zum-sieg-von-sebastian-vettel-in-melbourne'
#url = 'https://blog.miguelgrinberg.com/post/easy-web-scraping-with-python'
url = 'http://www.sport1.de/motorsport/formel1/2017/05/formel-1-jenson-button-denkt-an-fortsetzung-der-karriere'

a = Article(url, language='de') # Chinese

a.download()
a.parse()
print(a.top_image)
print(a.title)
html_content = '<a href="{0}" target="_blank"><img src="{0}"></img></a>'.format(a.top_image) + a.text
print( html_content )
page = telegraph.createPage( title = a.title,  html_content= html_content, author_name="f126ck" )
url2send = 'http://telegra.ph/' + page['path']
bot.sendMessage(chat_id = 31923577, text = url2send)
from telegraphapi import Telegraph
import telegram

def getTimeReadingString( words ):
	lung = len(words)
	#print( str( len(words) )	)
	minutes = len(words) / MY_ITALIAN_READING_PER_MINUTE
	#print(	"minutes " + str(minutes)	)
	if minutes == 0:
		return str(lung) + " parole.\n~1 min."
	timeReading = str(lung) + " parole.\n~" + str( int(minutes) )  + " min, " + str( round( (minutes-int(minutes) ) * 60 ) ) + " sec"
	return timeReading
	#print(timeReading)

MY_ITALIAN_READING_PER_MINUTE = 235
telegraph = Telegraph()
telegraph.createAccount("PythonTelegraphAPI")
TOKEN_TELEGRAM = '365418655:AAGSk21qAGVEdOxPEU9_aRXkp3zkmgSdIOc' #RcalcolatoBot
MY_CHAT_ID_TELEGRAM = 31923577
bot = telegram.Bot(TOKEN_TELEGRAM)

url = 'https://www.rischiocalcolato.it/blogosfera/la-guerra-commerciale-di-trump-244159.html'
url = 'https://www.rischiocalcolato.it/2017/04/la-nostra-sfida-piu-grande.html'
url = 'https://www.rischiocalcolato.it/2017/04/alla-base-della-razionalita-economica-proprieta-privata-decentramento-decisionale.html'
url = 'https://www.rischiocalcolato.it/2017/03/leuropa-impone-la-teoria-gender-che-non-ce-700-mila-firme-contro.html'


def getArticleContent( url ):
	req = urllib.request.Request(
		url, 
		data=None,