Example #1
0
def get_flats_info(url):
    response = requests.get(url)
    soup = BeautifulSoup(response.content, 'html.parser')
    db_file = "flats_olx.db"

    # Search all novostroys and add them into the list
    all_flats = soup.find_all("tr", class_="wrap")
    list_of_novostroys = []
    for td in all_flats:
        current_title = td.h3
        title_text = td.h3.get_text()

        if ("новостр" in title_text or "Новостр" in title_text):
            # formated_title_text = ' '.join(title_text.split())
            # list_of_flats.append((formated_title_text,))
            link_of_novostroy = current_title.a['href']
            list_of_novostroys.append(link_of_novostroy)

    # Then check DB. Delete links from list if they are already in the list
    # and add in DB new links

    db_connection = create_connection(db_file)

    # Get headers from all novostroys
    flats_info = get_headlines(list_of_novostroys)

    # actual_list = update_list(list_of_novostroys)
    unique_flats = input_new_titles(db_connection, flats_info)
    db_connection.close()

    return unique_flats
def show_bbc_hl(newssource):
    """ to get the Headline news from BBC,CNN,API,Google or New York Times"""


    bbc_dict = get_headlines(newssource)
    if newssource == 'bbc-news':
        headline_string = "BBC Headline News"
    elif newssource == 'bloomberg':
        headline_string = "Bloomberg Headline News"
    elif newssource == 'cnn':
        headline_string = "CNN Headline News"
    elif newssource == 'associated-press':
        headline_string = 'Associated Press Headline News'
    elif newssource =='google-news':
        headline_string = "Google Headline News"
   
    url = bbc_dict['url']
    title = bbc_dict['title']
    description = bbc_dict['description']

    return render_template("headlines.html",headline_string=headline_string,url=url,title=title,description=description)
            print("I was built by Ashwin Kumar Ramaswamy")

        elif "open stackoverflow" in statement:
            webbrowser.open_new_tab("https://stackoverflow.com/login")
            speak("Here is stackoverflow")

        elif 'news' in statement:
            news = webbrowser.open_new_tab(
                "https://timesofindia.indiatimes.com/home/headlines")
            speak(
                'Here are some headlines from the Times of India,Happy reading'
            )
            speak(
                'If you like the headline, say "visit" to open the page and read details'
            )
            headlines = headlines.get_headlines(
                "https://timesofindia.indiatimes.com/home/headlines")
            for i in range(15):
                speak(headlines['text'][i])
                command = takeCommand()
                if 'visit' in command:
                    webbrowser.open_new_tab(headlines['link'][i])
                    break
                elif 'stop' in command:
                    break
                time.sleep(5)
            time.sleep(6)

        elif "camera" in statement or "take a photo" in statement:
            ec.capture(0, "robo camera", "img.jpg")

        elif 'search' in statement: