def cm_get_info(url):
import json
import urllib.request
import re
def between(start, end, string):
return re.findall(re.escape(start)+'(.*?)'+re.escape(end), string, flags=re.DOTALL)[0]
headers = {
"User-Agent": r"Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:96.0) Gecko/20100101 Firefox/96.0"
}
resp = urllib.request.urlopen(urllib.request.Request(url, headers=headers)).read().decode("UTF-8")
data = between('<script>window.cloudSettings =', ';</script>', resp).replace('/', r'\/')
data = re.sub(r'"[^"]+x3c.*?",', '"",', data)
return json.loads(data)
def cm_get_direct_link(url):
data = cm_get_info(url)
return "/".join([
data["dispatcher"]["weblink_get"][0]["url"],
data["request"]["weblink"]
])
direct_link = cm_get_direct_link("https://cloud.mail.ru/public/5poV/cRDxAbPEQ")
print(direct_link)
import time
import math
timelimit=5
starttime = time.time()
a=2
b=5
r=input(f"Сколько будет {a} + {b}?")
endtime = time.time()
diff = math.floor(endtime - starttime)
if diff <= timelimit:
if int(r) == a+b:
print("Правильно")
else:
print("Ошибка")
else:
print(f"Вы не успели за {timelimit} секунд. Прошло {diff}.")
Using username "root".
Authenticating with public key "imported-openssh-key"
Linux v43195 4.9.0-16-amd64 #1 SMP Debian 4.9.272-2 (2021-07-19) x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
root@v43195:~# python3
Python 3.7.2 (default, Oct 10 2020, 15:44:37)
[GCC 6.3.0 20170516] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>>
>>> listener = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> listener.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
>>> listener.bind(('0.0.0.0', 9999))
>>> listener.listen(0)
>>> print("Wait")
Wait
>>> listener.accept()
(<socket.socket fd=4, family=AddressFamily.AF_INET, type=SocketKind.SOCK_STREAM, proto=0, laddr=('46.17.45.71', 9999), raddr=('5.101.156.100', 56353)>, ('5.101.156.100', 56353))
>>> print("Connect")
Connect
>>>
Using username "x90048bt".
Pre-authentication banner message from server:
| Welcome to LTD BeGet SSH Server 'bigbone'
End of banner message from server
Authenticating with public key "imported-openssh-key"
Welcome to Ubuntu 12.04.5 LTS (GNU/Linux 4.9.207-1-beget-acl x86_64)
* Documentation: https://help.ubuntu.com/
Last login: Sun Jan 2 18:58:44 2022 from 85.249.21.110
x90048bt@bigbone:~ [0] $ python
Python 2.7.3 (default, Oct 26 2016, 21:01:49)
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import socket
>>> connection = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
>>> connection.connect(('46.17.45.71', 9999))
>>> connection.close()
>>>
from bs4 import BeautifulSoup
from urllib.request import urlopen
from json import dumps
url = "https://rozklad.ztu.edu.ua/schedule/group/%D0%86%D0%9F%D0%97-21-3?new"
bs=BeautifulSoup(urlopen(url).read(), features="lxml")
schedule = []
schedule_table = bs.find("table", attrs={"class":"schedule"})
for tr in schedule_table.findAll("tr"):
if str(tr.th.text).strip() == "":
continue
tds = tr.findAll("td")
for td in tds:
newitem = {
"day": td.get("day")[0:-2],
"hour": td.get("hour")
}
if len(td.get("class")) > 0:
newitem.update({
"content": {
"variative": {
"subject": td.find("div", attrs={"class":"subject"}).text.strip(),
"room": td.find("span", attrs={"class":"room"}).parent.text.strip(),
"room_span": td.find("span", attrs={"class":"room"}).text.strip(),
"room_changed": "changed" in td.find("span", attrs={"class":"room"}).get("class"),
"teacher": td.find("div", attrs={"class":"teacher"}).text.strip(),
}
}
})
schedule.append(newitem)
print(dumps(schedule, indent = 4, ensure_ascii = False))
# так можно фильтровать
wednesdays = [d for d in schedule if d["day"] == "Середа"]
print(dumps(wednesdays, indent = 4, ensure_ascii = False))
# и так по любому из параметров
PassengerEnabled On
PassengerPython /usr/bin/python
Готово!#!/usr/bin/env python2
#-*- coding: utf-8 -*-
print("Content-type: text/html")
print("\n")
print("<h1>Hello world!</h1>")