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))
# и так по любому из параметров <?php
if ($_SERVER['REQUEST_METHOD'] == "POST") {
header('Content-type: text/plain; charset=utf-8');
$to = "damirgaliev587@gmail.com";
$tema = "Форма обратной связи на PHP";
$message = "Ваше имя: ".htmlspecialchars($_POST['name'])."<br>";
$message .= "E-mail: ".htmlspecialchars($_POST['email'])."<br>";
$message .= "Номер телефона: ".htmlspecialchars($_POST['phone'])."<br>";
$message .= "Сообщение: ".htmlspecialchars($_POST['message'])."<br>";
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
mail($to, $tema, $message, $headers);
}
header('Location: index.html');
?> R::getAll( 'select * from yourtablename where email = :email',
array(':email'=>$_POST['email'])
);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>")