コード例 #1
0
ファイル: shell.py プロジェクト: sphrilix/spotibot
 def main(self):
     print("____Hello, i'm here to serve you with streams!____")
     threads = pyip.inputNum(
         "Please enter how much bots should run (must be smaller then amount of accounts!): "
     )
     song_url = pyip.inputURL("Please enter the URL of your song: ")
     song_play_time = pyip.inputNum(
         "Please enter the play time (must be smaller then the length of the song): "
     )
     song_play_tolerance = \
         pyip.inputNum("Please enter the tolerance of play time (must be smaller then play time): ")
     self.start_bots(song_play_time, song_play_tolerance, song_url, threads)
     if pyip.inputYesNo("End Program: ") == "yes":
         self.terminate()
コード例 #2
0
# importing module
from pytube import YouTube
from pathlib import Path
import pyinputplus as pyip
import logging

program = True

#yt = ''
logging.basicConfig(level=logging.DEBUG,
                    format='%(asctime)s - %(levelname)s - %(message)s')

# main loop
while program:
    # Getting YT link
    ytLink = pyip.inputURL('Provide YouTube link:')

    # Trying to create YT object
    try:
        yt = YouTube(ytLink)
    except:
        print(
            'Error occured. It could be connection error or check your URL validity'
        )
        # program = False
        break
    # let user to choose quality of the movie or only audio
    quality = pyip.inputChoice(['high', 'low', 'only audio'],
                               'Choose quality: (high, low, only audio):')
    if quality == 'low':
        stream = yt.streams.get_lowest_resolution()
コード例 #3
0
# Instalar biblioteca
# pip install pyinputplus

from pyinputplus import inputNum, inputURL, inputEmail

# Aceita uma string
email = inputEmail(prompt='Digite seu email: ')
# Digite seu email: [email protected]

# Aceita apenas uma string no formato de url, retornando a string
url = inputURL(prompt='Digite uma url: ')
# Digite uma url: erickson.com.br

# Aceita apenas um número inteiro, Retornando um int, não um str.
num = inputNum(prompt='Digite um número: ')
# Digite um número: 369

# OUTROS TESTES
# MENU
# variavel = inputMenu(['Cachorro', 'Gato', 'Boi'])
# variavel = inputMenu(['Cachorro', 'Gato', 'Boi'], numbered=True)
# variavel = inputMenu(['Cachorro', 'Gato', 'Boi'], lettered=True)

# NUMERO
# variavel = inputNum('Digite um número: ')
# variavel = inputNum('Digite um número: ', max=9)

# CHOICES
# variavel = inputChoice(['1', '2'])
# try:
#     variavel = inputChoice(['1', '2'], limit=2)
コード例 #4
0
#! python3
# comic_downloader.py - Downloads all comic images for a series
# Created by Teng Mao @https://github.com/TengCXXI
# With references to "Automate the Boring Stuff with Python" by Al Sweigart

import requests, os, bs4, time
import pyinputplus as pyip
from pathlib import Path

url = pyip.inputURL(
    "Please provide the url for the comic to download, starting from the first page you want: "
)

comic_name = pyip.inputStr("Please provide the comic name: ")

comic_folder_path = './comics/' + comic_name

# Create a folder with the comic name to store the images
os.makedirs(comic_folder_path, exist_ok=True)

while True:

    # Download the page
    print('Downloading page %s...' % url)
    res = requests.get(url)
    res.raise_for_status()

    soup = bs4.BeautifulSoup(res.text, 'html.parser')

    # Create the URL for the home site for URL extraction functions
    site_home = str(Path(url).parents[len(Path(url).parents) - 3])
                counter += 1
            elif unformatted_url.startswith(('#', '../', '.')):
                formatted_url = f'{os.path.dirname(url)}/{unformatted_url}'
                counter += 1
            elif unformatted_url.startswith('/'):
                parsed_url = urlparse(url)
                formatted_url = f'{parsed_url.scheme}://{parsed_url.hostname}/{unformatted_url}'
                counter += 1

            url_res = requests.get(formatted_url)
            is_link_verified(url_res, formatted_url)


def is_link_verified(response, url):
    try:
        response.raise_for_status()
        return True
    except Exception as exc:
        if response.status_code == 404:
            print(f'404 Error: The link {url} is a broken link.')
        else:
            print(f'There was a problem: {exc}')
        return False


if __name__ == '__main__':
    input_url = pyip.inputURL(
        prompt="Please enter the full URL to download the linked pages from:\n"
    )
    download_linked_pages(input_url)
import pyinputplus as pyip, ezsheets


def download_google_forms_data(url):
    ss = ezsheets.Spreadsheet(url)

    # Assuming form responses are on the first sheet
    responses_sheet = ss[0]

    # The email addresses are stored in the third column, only want values that have non empty email addresses
    email_address_responses = [
        response for response in responses_sheet.getColumn(3) if response
    ]

    # If only value is the form question, return
    if len(email_address_responses) == 1:
        return

    print('*' * 10, 'Email addresses from the Google Form:', '*' * 10)

    # Skip the row containing the form question
    for i in range(1, len(email_address_responses)):
        print(f'Email address: {email_address_responses[i]}')


if __name__ == '__main__':
    google_sheet_url = pyip.inputURL(
        prompt=
        'Enter the URL of the google sheet containing the form results:\n')
    download_google_forms_data(google_sheet_url)