tp_links = []
for x in range(1,3+1):
tp_links.append('tp-link '+str(x))
print(tp_links)
['tp-link 1', 'tp-link 2', 'tp-link 3']
pip will fetch and install PyAudio wheels (prepackaged binaries). Currently, there are wheels compatible with the official distributions of Python 2.7, 3.4, 3.5, and 3.6. For those versions, both 32-bit and 64-bit wheels are available.
import requests
from bs4 import BeautifulSoup
import re
url = 'https://www.nic.ru/whois/?searchWord=youtube.com'
r = requests.get(url)
response = r.content
soup = BeautifulSoup(response, 'html.parser')
information = soup.find('div', attrs={'class': '_3U-mA _23Irb'})
inf = information.text.splitlines()
for x in inf:
if 'Creation Date:' in x:
creation_date = x.split('Creation Date:')[-1].strip()
print(creation_date)
from tkinter import *
def get_num():
value = message.get()
print(value)
root = Tk()
root.title('Угадай число')
root.geometry("200x300+450+100")
Label(root, text='Введите число:', font='0.5').place(x=40, y=30, bordermode=OUTSIDE)
message = StringVar()
number = Entry(root,textvariable=message, width=20).place(x=40, y=70)
btn = Button(text='Угадать', command=get_num, font='5', padx='25', pady='5').place(x=40, y=200, bordermode=OUTSIDE)
root.mainloop()
import sqlite3
import time
from datetime import datetime
conn = sqlite3.connect('events.db')
cursor = conn.cursor()
sql = """CREATE TABLE IF NOT EXISTS events(id INTEGER PRIMARY KEY AUTOINCREMENT,
page int,
status text,
date text)"""
cursor.execute(sql)
def add_event(page,status): # Метод добавления в базу: page - номер текущей страници, status - OK или ERROR
date_now = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
cursor.execute("INSERT INTO events VALUES(?,?,?,?)",(None, page, status, date_now))
conn.commit()
pass
max_page = 5
for page in range(1,max_page+1):
try:
# Тут сам парсинг, или метод парсинга
print(f'Завершено скачивание данных {str(page)} из {str(max_page)} страниц')
add_event(page,'OK')
time.sleep(0.5)
except:
print(f'Ошибка парсинга на странице {page}')
add_event(page,'ERROR')
conn.close()