Skip to content

Commit

Permalink
Endpoint is now in an env var and webhook is being retrieved by a req…
Browse files Browse the repository at this point in the history
…uest to a server
  • Loading branch information
bojo509 committed Jan 7, 2025
1 parent 73007a1 commit a527218
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions parfium.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import requests
import time
import logging
import os
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.chrome.service import Service as ChromeService
Expand All @@ -15,9 +16,6 @@
# Set up logging
logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(message)s')

# Discord webhook URL
webhook_url = "https://discord.com/api/webhooks/1284168278335291474/-i1m-VGJk-sFcljJzD7ICGbVrP7sQin3k0A8qo4OZksHEs9_XlMqkIxLHUQSt9oBfK9F"

# Initialize the WebDriver service
service = ChromeService(ChromeDriverManager().install())

Expand Down Expand Up @@ -51,7 +49,7 @@ def create_driver(headless):

def send_discord_message(content):
data = {"content": content}
response = requests.post(webhook_url, json=data)
response = requests.post(webhook['url'], json=data)
if response.status_code == 204:
logging.info("Webhook message sent successfully!")
else:
Expand Down Expand Up @@ -136,17 +134,16 @@ def main():
if __name__ == "__main__":
try:
logging.info("Starting the script")
endpoint = "https://perfumes.jobify.one"
shortIdResponse = requests.get("https://perfumes.jobify.one/shortidendpoint")
endpoint = os.getenv('ENDPOINT')

shortIdResponse = requests.get(endpoint + "/shortidendpoint")
shortIdResponse.raise_for_status()
shortIdData = shortIdResponse.json()
url = shortIdData["url"]

healthcheck = requests.get(endpoint + '/health-check')
while healthcheck.status_code != 200:
logging.error("Trying to wake the server up")
time.sleep(5)
healthcheck = requests.get(endpoint + '/health-check')
webhook = requests.get(endpoint + "/webhook")
webhook.raise_for_status()
webhook = webhook.json()

logging.info(f"Fetching URLs from {endpoint}")
urls = fetch_urls(endpoint)
Expand Down

0 comments on commit a527218

Please sign in to comment.