Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions disc/cog.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from discord_slash.utils.manage_components import create_button

from job_boards_scrapers import LinkedIn
from levels_salary_scraper import Levels
from utils import Colors


Expand All @@ -25,6 +26,14 @@ class Slash(commands.Cog):
def __init__(self, bot):
self.bot = bot
self.linkedin_job_api = LinkedIn()
self.levels = Levels()


@cog_ext.cog_slash(name="view-salary", description=Descriptions.POST_JOB)
async def _view_salary(self, ctx: SlashContext, company: str):

data = self.levels.get_salary_info(company)
await ctx.send(f"Here is the salary for {company.capitalize()} software engineers (level/tc/base/stock/bonus):\n{data.level} - {data.total} - {data.base} - {data.stock} - {data.bonus}")

@cog_ext.cog_slash(name="post-job", description=Descriptions.POST_JOB)
async def _post_job(self, ctx: SlashContext, url_or_jobid: str):
Expand Down
1 change: 1 addition & 0 deletions levels_salary_scraper/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
from levels_salary_scraper.levels import Levels
57 changes: 57 additions & 0 deletions levels_salary_scraper/base.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
from dataclasses import dataclass
from re import S
import html2text
import requests
from bs4 import BeautifulSoup as bs

@dataclass
class SalaryInfo:
level: str
total: str
base: str
stock: str
bonus: str

class Levels:
def __init__(self, company) -> None:
self.base_link = "https://www.levels.fyi/companies/" + company + "/salaries/software-engineer"

class Salary:
_html2text: html2text.HTML2Text

_level_key: str
_total_key: str
_base_key: str
_stock_key: str
_bonus_key: str

def __init_sublass__(cls) -> None:
cls._html2text = html2text.HTML2Text()
cls._html2text.body_width = 0

def get_company_info(self, company):
pass

def _extract_from_comapny_view(self, url: str):
headers = {'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36'}

response = requests.get(url, headers=headers)
print(response)
print(url)
html = response.content
soup = bs(html, "lxml")


level = soup.findAll("a", class_="MuiTypography-root MuiTypography-inherit MuiLink-root MuiLink-underlineHover css-3aax9m")[2].get_text()
total = soup.findAll("h6", class_="MuiTypography-root MuiTypography-subtitle1 css-idrr7q")[0].get_text()
base = soup.findAll("h6")[14].get_text()
stock = soup.findAll("h6")[16].get_text()
bonus = soup.findAll("h6")[19].get_text()

return SalaryInfo(
level,
base,
stock,
total,
bonus
)
17 changes: 17 additions & 0 deletions levels_salary_scraper/levels.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
from levels_salary_scraper.base import Salary, SalaryInfo

class Levels(Salary):

_MAIN_VIEW_PREFIX = "https://www.levels.fyi/companies/"
_MAIN_VIEW_SUFFIX = "/salaries/software-engineer"

def __init__(self) -> None:
self._level_key = ""
self._total_key = ""
self._base_key = ""
self._stock_key = ""
self._bonus_key = ""


def get_salary_info(self, company):
return self._extract_from_comapny_view(self._MAIN_VIEW_PREFIX + company + self._MAIN_VIEW_SUFFIX)