diff --git a/README.md b/README.md index e00caf4..bf3e15b 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -# Upwork_Slackbot \ No newline at end of file +# Upwork SlackBot \ No newline at end of file diff --git a/config.py b/config.py new file mode 100644 index 0000000..a6e33a7 --- /dev/null +++ b/config.py @@ -0,0 +1,5 @@ +import os + +CONSUMER_KEY = os.environ['CONSUMER_KEY'] +CONSUMER_SECRET = os.environ['CONSUMER_SECRET'] +QUERY = os.environ['QUERY'] \ No newline at end of file diff --git a/main.py b/main.py new file mode 100644 index 0000000..e69de29 diff --git a/upwork/__init__.py b/upwork/__init__.py new file mode 100644 index 0000000..a924e9b --- /dev/null +++ b/upwork/__init__.py @@ -0,0 +1,2 @@ +from upwork.bot import Bot +from upwork.client import client \ No newline at end of file diff --git a/upwork/bot.py b/upwork/bot.py index fe95958..a54db3c 100644 --- a/upwork/bot.py +++ b/upwork/bot.py @@ -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) \ No newline at end of file +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 \ No newline at end of file diff --git a/upwork/client.py b/upwork/client.py index 883e796..21d3fdb 100644 --- a/upwork/client.py +++ b/upwork/client.py @@ -1,11 +1,6 @@ import upwork from pprint import pprint from upwork.routers import auth -from config import ( - CONSUMER_KEY, - CONSUMER_SECRET - -) class Client: @@ -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 diff --git a/upwork/config.py b/upwork/config.py deleted file mode 100644 index 5562780..0000000 --- a/upwork/config.py +++ /dev/null @@ -1,4 +0,0 @@ -import os - -CONSUMER_KEY = os.environ['CONSUMER_KEY'] -CONSUMER_SECRET = os.environ['CONSUMER_SECRET'] \ No newline at end of file