import com.codeborne.selenide.Selenide;
import org.openqa.selenium.Cookie;
import java.util.Set;
public class CookieExample {
public static void main(String[] args) {
Selenide.open("https://example.com/login");
Set<Cookie> cookies = Selenide.getWebDriver().manage().getCookies();
for (Cookie cookie : cookies) {
if (cookie.getName().equals("refresh")) {
String refreshToken = cookie.getValue();
System.out.println("Refresh Token: " + refreshToken);
}
}
}
}
dependencies {
implementation 'com.codeborne:selenide:6.10.0'
}
.container:has(.image) {
display: block;
}
.container:has(.image:only-child) {
text-align: center;
}
.container:has(.image) p {
display: inline-block;
min-width: 150px;
width: calc(100% - 200px);
}
.image {
float: left;
max-width: 150px;
margin: 0 10px 10px 0;
}
.container:has(.image) p:not(:only-child) {
clear: both;
display: block;
text-align: center;
}
.case-wrapper {
position: relative;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
outline: none;
background: transparent;
border: none;
padding: 0;
margin: 0;
box-shadow: none;
}
.case-wrapper:focus {
outline: none;
box-shadow: none;
}
.case-wrapper::-moz-focus-inner {
border: 0;
}
$(".show-more").click(function () {
if($("#text-more").hasClass("expanded")) {
$(this).text("показать все товары");
} else {
$(this).text("скрыть товары");
}
$("#text-more").slideToggle(1000).toggleClass("expanded");
});
ef test_post_task_create(self):
form_data = {
'name': 'Totoro',
'description': 'must watch it!',
'status': self.status2.id,
}
response = self.client.post(reverse('task_create'), form_data, follow=True)
self.assertEqual(response.status_code, 302)
self.assertTrue(Task.objects.filter(name='Totoro').exists())
task = Task.objects.get(name='Totoro')
self.assertEqual(task.author_id, self.user.id)
self.assertEqual(task.author.first_name, 'Al')
self.assertRedirects(response, '/tasks/')
self.assertEqual(task.status.id, self.status2.id)
import random
media_ids = {
'photos': [],
'videos': []
}
@bot.message_handler(content_types=['photo', 'video'])
def save_media(message):
group_id_1 = 'MYGROUP_ID'
if message.chat.id == int(group_id_1):
if message.content_type == 'photo':
file_id = message.photo[-1].file_id
media_ids['photos'].append(file_id)
elif message.content_type == 'video':
file_id = message.video.file_id
media_ids['videos'].append(file_id)
@bot.message_handler(content_types=['text'])
def media_frwrd(message):
if message.chat.type == 'private':
if message.text == 'Фото':
if media_ids['photos']:
random_photo_id = random.choice(media_ids['photos'])
bot.send_photo(message.chat.id, random_photo_id)
else:
bot.send_message(message.chat.id, "Нет доступных фото.")
elif message.text == 'Видео':
if media_ids['videos']:
random_video_id = random.choice(media_ids['videos'])
bot.send_video(message.chat.id, random_video_id)
else:
bot.send_message(message.chat.id, "Нет доступных видео.")
.createButton {
height: 3rem;
width: 3rem;
border-radius: 50%;
color: #FFF;
background: var(--green-color);
display: flex;
align-items: center;
justify-content: center;
font-size: 3rem;
font-weight: 600;
line-height: 1;
}
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import java.io.FileInputStream;
import java.io.IOException;
public class Main {
public static void main(String[] args) throws IOException {
FileInputStream file = new FileInputStream("C:\\Users\\user\\Downloads\\report.xlsx");
XSSFWorkbook workbook = new XSSFWorkbook(file);
XSSFSheet sheet = workbook.getSheetAt(0);
workbook.close();
file.close();
}
}
forwarded_message = await app.forward_messages(chat_id=destination_chat_id, from_chat_id=source_chat_id, message_ids=message_id)
await app.send_message(chat_id=destination_chat_id, text="Ответ на пересланное сообщение", reply_to_message_id=forwarded_message.message_id)
const http = require('http');
const httpProxy = require('http-proxy');
const proxy = httpProxy.createProxyServer({});
http.createServer(function(req, res) {
proxy.web(req, res, {
target: 'https://game-analytics.ru',
changeOrigin: true,
selfHandleResponse: true
});
proxy.on('proxyRes', function(proxyRes, req, res) {
let body = [];
proxyRes.on('data', function(chunk) {
body.push(chunk);
});
proxyRes.on('end', function() {
body = Buffer.concat(body);
res.setHeader('Content-Security-Policy', '');
res.writeHead(proxyRes.statusCode, proxyRes.headers);
res.end(body);
});
});
}).listen(3000, () => {
console.log('Прокси-сервер запущен на порту 3000');
});
<html lang="ru">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Создание Iframe через JavaScript</title>
</head>
<body>
<div id="iframe-container"></div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const iframe = document.createElement('iframe');
iframe.setAttribute('src', 'http://localhost:3000');
document.getElementById('iframe-container').appendChild(iframe);
});
</script>
</body>
</html>
@app.on_chat_member_updated()
async def on_chat_member_updated(client, chat_member_updated: ChatMemberUpdated):
if chat_member_updated.new_chat_member.user.is_self:
while True:
message = "Какое-то сообщение..."
await client.send_message(chat_member_updated.chat.id, message)
await asyncio.sleep(180)
from selenium import webdriver
driver = webdriver.Chrome()
driver.get("https://google.com")
driver.execute_script("window.localStorage.setItem('key', 'value');")
driver.execute_script("window.sessionStorage.setItem('key', 'value');")
local_storage_value = driver.execute_script("return window.localStorage.getItem('key');")
session_storage_value = driver.execute_script("return window.sessionStorage.getItem('key');
$("#modal").off('submit').on('submit', function (e) {
e.preventDefault();
var form_data = $(this).serialize();
$.ajax({
type: "POST",
url: "user/add.php",
data: form_data,
success: function (html) {
document.getElementById("shadow").style.display = "none";
document.getElementById("modal").style.display = "none";
$('#modal').trigger('reset');
$("#main").append(html);
}
});
});
require "../database/Task.php";
if (isset($_POST['title']) && isset($_POST['description'])) {
$task_mess = new Task;
$task_mess->add_task($_POST['title'], $_POST['description']);
$new_task = $task_mess->get_last_task();
echo "<div class='task'>
<h3>{$new_task['title']}</h3>
<p>{$new_task['description']}</p>
</div>";
}
#include <stdio.h>
#include <stdlib.h>
int main() {
char str[12];
double number = 0;
printf("Enter a number to edit: ");
gets(str);
int i = 0, j = 0;
char editedStr[12];
int dot_found = 0;
printf("Entered number : %s\n", str);
while (str[i] != '\0') {
if (str[i] == ',' || str[i] == '.') {
if (!dot_found) {
editedStr[j++] = '.';
dot_found = 1;
}
} else {
editedStr[j++] = str[i];
dot_found = 0;
}
++i;
}
editedStr[j] = '\0';
printf("Edited number but not converted: %s\n", editedStr);
number = atof(editedStr);
printf("Edited number: %f\n", number);
return 0;
}
Я просто не могу выделить части кода в отдельные методы. Мне нужно чтобы мой код размещался в разных методах...
IBrowser browser;
IPage page;
async Task InitializeBrowserAsync()
{
var playwright = await Playwright.CreateAsync();
browser = await playwright.Chromium.LaunchAsync(new BrowserTypeLaunchOptions { Headless = false });
page = await browser.NewPageAsync();
}
async Task CreateRegistryAsync()
{
await page.GetByRole(AriaRole.Button, new() { Name = "Создать реестр" }).ClickAsync();
string strKitCategory = templateSheet.GetCell(currentSheetRow, (int)ExcellTemplateTableSheet.ColumnType.kitCategory);
await page.GetByText(strKitCategory).ClickAsync();
}
async Task FillDetailsAsync()
{
string rChKit = templateSheet.GetCell(currentSheetRow, (int)ExcellTemplateTableSheet.ColumnType.RCHKit);
await page.GetByLabel("Комплект РЧ").FillAsync(rChKit);
await page.GetByText(rChKit).ClickAsync();
}
async Task SubmitRegistryAsync()
{
string worcksDescription = templateSheet.GetCell(currentSheetRow, (int)ExcellTemplateTableSheet.ColumnType.descriptionOfWorks);
await page.GetByLabel("Описание работ").FillAsync(worcksDescription);
await page.GetByRole(AriaRole.Button, new() { Name = "Создать", Exact = true }).ClickAsync();
}
async Task MainAsync()
{
await InitializeBrowserAsync();
await CreateRegistryAsync();
await FillDetailsAsync();
await SubmitRegistryAsync();
}
async Task InitializePersistentContextAsync()
{
var playwright = await Playwright.CreateAsync();
var browser = await playwright.Chromium.LaunchPersistentContextAsync("PATH", new BrowserTypeLaunchPersistentContextOptions { Headless = false });
page = browser.Pages.First();
}