def wrap_back(text: [str, int, float, Any], color: str = Back.GREEN) -> str:
"""
:param text: stuff that can be transformed to string
:param color: really a AnsiCodes/AnsiBack
:return: your wrapped string
"""
return f'{color}{text}{Style.RESET_ALL}'
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
""" | |
This test is to illustrate that child classes have a different base class object as their parent. | |
""" | |
class Monitor: | |
reqs_sent = 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
import sys | |
from pathlib import Path | |
def get_project_root() -> str: | |
""" | |
This fx is super important! | |
Literally everything acts up if this isn't good. | |
""" | |
if getattr(sys, 'frozen', False): |
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 sys | |
from datetime import datetime | |
from os import system | |
from typing import Any | |
from colorama import Back, Style, Fore | |
def update_title(terminal_title, force: bool = False): | |
if not force: |
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 json import dumps, JSONDecodeError, loads | |
from typing import Union | |
import httpx | |
from bs4 import BeautifulSoup | |
from colorama import Fore, Back, Style | |
from playwright import async_api | |
from utils.root import get_project_root | |
from utils.terminal import color_wrap |
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 aiohttp import ClientSession, ClientRequest | |
class CustomRequestClass(ClientRequest): | |
DEFAULT_HEADERS = {} | |
pass | |
async def main(): | |
async with ClientSession(headers={"User-Agent": 'Dario\'sGodBot', "Host": "httpbin.org"}, | |
request_class=CustomRequestClass) \ | |
as sesh: | |
res = await sesh.request(method='GET', url='http://httpbin.org/get') |
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 requests import Session | |
from pandas import DataFrame | |
from bs4 import BeautifulSoup as bs | |
from time import time | |
t1 = time() | |
main_session = Session() | |
page = main_session.get('https://en.wikipedia.org/wiki/Greater_Toronto_and_Hamilton_Area').content | |
page = bs(page, 'lxml') | |
dump = [] |
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
dump.append({ | |
"City": element.text, | |
"Average Property Price": avg_prop_price, | |
"10 Year Rate of Change": ten_years_roc, | |
"5 Year Rate of Change": five_years_roc, | |
"1 Year Rate of Change": one_year_roc, | |
"3 Bedroom Home Price": three_bed_home, | |
"Url": url | |
}) | |
print(f"Done scraping {element.text}") |
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
url = f"https://{'-'.join(element.text.split()).lower()}.listing.ca/real-estate-prices-by-community.htm" | |
print(url) | |
resp = main_session.get(url) | |
print(resp.url) | |
listing_ca_page = bs(resp.content, 'lxml') | |
three_bed_home = listing_ca_page.find('a', attrs={'href': '/3-bedroom-detached-home' | |
'-prices-by-community.htm'})\ | |
.next.next.text.strip() # avg price of detached 3 bedroom home |
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 requests import Session | |
from pandas import DataFrame | |
from bs4 import BeautifulSoup as bs | |
from time import time | |
t1 = time() | |
main_session = Session() | |
page = main_session.get('https://en.wikipedia.org/wiki/Greater_Toronto_and_Hamilton_Area').content | |
page = bs(page, 'lxml') | |
dump = [] |
NewerOlder