Esempio n. 1
0
    def eng_news(self, con, grp_type):
        c = con.cursor()
        msg = ''
        urli = url['indiatoday']
        res = requests.get(urli)

        if (res.status_code == 200):
            soup = BeautifulSoup(res.content, 'lxml')
            clean_data = soup.find("div", {'class': 'catagory-listing'})
            # print(clean_data)
            img = clean_data.find('img')['src']
            text_data = soup.find("div", {'class': 'detail'})
            para = clean_data.find('p')
            headline = clean_data.find('a')
            print(headline.text)

            if_news_exist = 'SELECT headline from {} where headline = "{}" '.format(
                tbl_covid_news, headline.text)
            existQ = c.execute(if_news_exist)
            existQ = existQ.fetchone()
            if (existQ is None or len(existQ) != 1):
                msg_date = time.strftime('%d/%m')
                msg += 'Covid-19 | Latest News | {}\n\n'.format(msg_date)
                msg += '<b>{}</b>\n\n'.format(headline.text)
                msg += '<i>{}</i>'.format(para.text)

                telegram.pushMessage(msg, 'Html', grp_type)

                cmdInsertData = 'INSERT INTO {} VALUES (?,?)'.format(
                    tbl_covid_news)
                c.execute(cmdInsertData, [headline.text, para.text])
                con.commit()
        else:
            print('Invalid Response')
Esempio n. 2
0
    def marathi_news(self, grp_type):
        urli = url['abplive_marathi']
        res = requests.get(urli)

        if (res.status_code == 200):
            soup = BeautifulSoup(res.content, 'lxml')
            title = soup.findAll("div", {'class': 'text-div'})

            for i in title[0:3]:
                para = i.text
                msg = ''
                msg += '<b>Covid-19 | Marathi | @covid_india</b>\n\n'
                msg += para

                telegram.pushMessage(msg, "Html", grp_type)
        else:
            print('Invalid Response')
Esempio n. 3
0
    def hindi_news(self, grp_type):
        msg = ''
        msg += '<b>Covid-19 | Hindi | @covid_india</b>\n\n'
        # url = 'https://www.mumbailive.com/hi/liveupdates/coronavirus-covid-19-live-updates'
        urli = url['khabar']
        res = requests.get(urli)

        if (res.status_code == 200):
            soup = BeautifulSoup(res.content, 'lxml')
            title = soup.findAll("p", {'class': 'header fbld'})
            para = soup.find("p", {'class': 'intro'})

            # print(clean_data[0].text)
            msg += title[0].text + '\n\n'
            msg += para.text.lstrip()

            telegram.pushMessage(msg, "Html", grp_type)
        else:
            print('Invalid Response')
Esempio n. 4
0
    def mhStat(self, grp_type):
        msg = ''
        msg += 'Covid-19 | @covid_india |' + time.strftime('%d/%m') + '\n\n'
        msg += 'Covid-19 Cases in Maharashtra\n'
        urli = url['mumbailive']
        res = requests.get(urli)

        if (res.status_code == 200):
            soup = BeautifulSoup(res.content, 'lxml')
            # title = soup.find("div",{'class':'container push-half--bottom'})
            title = soup.find("div", {'class': 'container push-half--bottom'})
            print(title.text)

            cases = title.findAll('small')
            for i in cases:
                msg += i.text + '\n'

            telegram.pushMessage(msg, 'Html', grp_type)
        else:
            print('Invalid Response')
Esempio n. 5
0
    def myth_buster(self, grp_type):
        msg = ''
        msg += '<b>Covid-19 | Myth Busters</b>\n\n'
        urli = url['who_myth']
        res = requests.get(urli)
        if (res.status_code == 200):
            soup = BeautifulSoup(res.content, 'lxml')
            clean_data = soup.findAll("h2")
            randno = random.randrange(0, len(clean_data))
            headline = clean_data[randno]
            para = clean_data[randno].next_sibling
            msg += str(headline.text) + '\n\n'
            msg += str(para.text)

            msg += '\n\n<i>Join @covid_india for more.</i>'

            print(msg)

            telegram.pushMessage(msg, 'Html', grp_type)
        else:
            print('Invalid Response')
Esempio n. 6
0
    def tamil_news(self, arg, grp_type):

        if (arg == 1):
            msg = ''
            msg += '<b>Covid-19 | Tamil | @covid_india</b>\n\n'
            # url = 'https://www.mumbailive.com/hi/liveupdates/coronavirus-covid-19-live-updates'
            urli = url['tamil_news18']
            # url = 'https://www.maalaimalar.com/Topic/coronavirus'
            res = requests.get(urli)

            if (res.status_code == 200):
                soup = BeautifulSoup(res.content, 'lxml')
                # title = soup.find("div",{'class':'lorbox liveb'})
                para = soup.findAll("p")

                # print(vars(title))
                msg += para[2].text + '\n\n'
                # msg += para.text.lstrip()
                # print(msg)
                # exit()

                telegram.pushMessage(msg, "Html", grp_type)

        if (arg == 2):
            msg = ''
            msg += '<b>Covid-19 | Tamil | @covid_india</b>\n\n'
            # url = 'https://www.mumbailive.com/hi/liveupdates/coronavirus-covid-19-live-updates'
            urli = url['toptamilnews']
            # url = 'https://www.maalaimalar.com/Topic/coronavirus'
            res = requests.get(urli)

            if (res.status_code == 200):
                soup = BeautifulSoup(res.content, 'lxml')
                title = soup.find("h4", {'class': 'post-title'})
                para = soup.find("p", {'class': 'post-entry'})

                msg += title.text + '\n\n'
                msg += para.text

                telegram.pushMessage(msg, "Html", grp_type)
Esempio n. 7
0
    def indiaStat(self, con, grp_type):
        c = con.cursor()
        msg = ''
        summary_post = {}
        sql_data = []
        urli = url['mohfw']
        res = requests.get(urli)

        if (res.status_code == 200):
            soup = BeautifulSoup(res.content, 'lxml')
            div = soup.find("div", {"class": "content newtab"})
            clean_data = div.find('table')
            rows = clean_data.find_all('tr')
            # print(rows)
            # exit()
            summary = rows[-1].find_all('td')
            summary_post['registered'] = sum(
                [int(summary[1].text),
                 int(summary[2].text)])
            summary_post['recovered'] = summary[3].text.replace('\n', '')
            summary_post['death'] = summary[4].text.replace('\n', '')
            print(summary_post)
            msg_date = time.strftime('%d/%m')
            msg += '­Ъда <b>INDIA Covid-19 Stats</b> ­Ъда - {}\n'.format(
                msg_date)
            msg += 'source : Ministry of Health & Family Welfare\n\n'
            msg += 'Registered - ' + str(summary_post['registered']) + '\n'
            msg += 'Recovered - ' + str(summary_post['recovered']) + '\n'
            msg += 'Death - ' + str(summary_post['death']) + '\n\n'
            # msg += '<b>State-wise Count</b>\n\n'
            msg += '<pre>State-Cases-Death</pre>\n'
            # exit()
            # rows.pop(0)
            # rows.pop(-1)
            # print(rows)

            reporting_date = datetime.date.today()

            if_data_exist = 'SELECT logged from {} where logged = "{}" '.format(
                tbl_covid_stats, reporting_date)
            if_data_exist = c.execute(if_data_exist)
            existQ = if_data_exist.fetchone()

            for r in rows[1:len(rows) - 1]:
                count = 0
                data = r.find_all('td')
                count = sum([int(data[2].text), int(data[3].text)])
                # print(data)

                msg += data[1].text + '-' + str(
                    count) + '-' + data[5].text + '\n'

                if (existQ is None or len(existQ) != 1):
                    sql_data = [
                        reporting_date, data[1].text, data[2].text,
                        data[3].text, data[4].text, data[5].text
                    ]
                    cmdInsertData = 'INSERT INTO {} VALUES (?,?,?,?,?,?)'.format(
                        tbl_covid_stats)
                    c.execute(cmdInsertData, sql_data)
                    con.commit()

            print(msg)
            world_update = self.worldStat()
            msg += world_update
            telegram.pushMessage(msg, 'Html', grp_type)
        else:
            print('Invalid Response')
Esempio n. 8
0
 def manualMsg(self, grp_type):
     msg = """ """
     if (msg == ' '):
         exit('Empty Msg')
     else:
         telegram.pushMessage(msg, 'Html', grp_type)