Skip to content

Commit

Permalink
[Restructure]: Restructure the repo into packages
Browse files Browse the repository at this point in the history
  • Loading branch information
keenborder786 committed May 16, 2023
1 parent 36036d0 commit d6524be
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 43 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
# Upwork_Slackbot
# Upwork SlackBot
5 changes: 5 additions & 0 deletions config.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import os

CONSUMER_KEY = os.environ['CONSUMER_KEY']
CONSUMER_SECRET = os.environ['CONSUMER_SECRET']
QUERY = os.environ['QUERY']
Empty file added main.py
Empty file.
2 changes: 2 additions & 0 deletions upwork/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
from upwork.bot import Bot
from upwork.client import client
55 changes: 25 additions & 30 deletions upwork/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,28 @@
from bs4 import BeautifulSoup




QUERY = 'Python'
def get_data():
"""
"""
driver = webdriver.Chrome()
driver.get(f"https://www.upwork.com/nx/jobs/search/?q={QUERY.replace(' ','%20')}&sort=recency")
jobs_layout = driver.find_element(By.CSS_SELECTOR,"div.up-card-section > div:nth-child(1) > div:nth-child(2)")
html_data = jobs_layout.get_attribute('outerHTML')
driver.close()
return html_data

def parser_data(html_data):
"""
"""
soup = BeautifulSoup(html_data, 'html.parser')
job_list =soup.find_all('section', attrs={'data-test': 'JobTile'})
jobs_data = {}
for job in job_list:
jobs_data[job.find('a')['href']] = job.text
return jobs_data


html_data = get_data()
jobs_data = parser_data(html_data)
class Bot:
def __init__(self,query):
self.query = query
def get_data(self):
"""
"""
driver = webdriver.Chrome()
driver.get(f"https://www.upwork.com/nx/jobs/search/?q={self.query.replace(' ','%20')}&sort=recency")
jobs_layout = driver.find_element(By.CSS_SELECTOR,"div.up-card-section > div:nth-child(1) > div:nth-child(2)")
html_data = jobs_layout.get_attribute('outerHTML')
driver.close()
return html_data
def parse_data(self, html_data):
"""
"""
soup = BeautifulSoup(html_data, 'html.parser')
job_list =soup.find_all('section', attrs={'data-test': 'JobTile'})
jobs_data = {}
for job in job_list:
jobs_data[job.find('a')['href']] = job.text
return jobs_data
8 changes: 0 additions & 8 deletions upwork/client.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import upwork
from pprint import pprint
from upwork.routers import auth
from config import (
CONSUMER_KEY,
CONSUMER_SECRET

)

class Client:

Expand Down Expand Up @@ -36,6 +31,3 @@ def _start_desktop_client(self):
) ## TODO: Get Auth Code Directly from https://www.upwork.com/ab/account-security/oauth2/authorize?response_type=token&client_id=CLIENT-ID-HERE&redirect_uri=https://a.callback.url
client.get_access_token(authz_code)
return client

def get_job_posting(self,query):
pass
4 changes: 0 additions & 4 deletions upwork/config.py

This file was deleted.

0 comments on commit d6524be

Please sign in to comment.