From 3107f216ec29827345dd705457c8cdc4ee0b9141 Mon Sep 17 00:00:00 2001 From: joey0629 Date: Tue, 23 Apr 2024 19:03:43 +0800 Subject: [PATCH] Update all headless mode v4 --- Test_forbidden.py | 12 ++++++++++++ main.py | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 Test_forbidden.py diff --git a/Test_forbidden.py b/Test_forbidden.py new file mode 100644 index 0000000..de2bdce --- /dev/null +++ b/Test_forbidden.py @@ -0,0 +1,12 @@ +import requests + +url = "https://www.bea.gov/news/2024/personal-income-and-outlays-february-2024" # 請將這裡替換為你的網址 + +response = requests.get(url) + +if response.status_code == 200: + print("Successfully accessed the website.") +elif response.status_code == 403: + print("Your IP is forbidden to access this website.") +else: + print(f"Received status code {response.status_code}.") \ No newline at end of file diff --git a/main.py b/main.py index f9624c4..ad8c22b 100644 --- a/main.py +++ b/main.py @@ -78,7 +78,7 @@ def find_pce(date:str): from selenium.webdriver.chrome.options import Options print("Start") options = Options() - options.add_argument('--headless') + # options.add_argument('--headless') options.add_argument('--no-sandbox') options.add_argument('--disable-dev-shm-usage') options.add_argument("--window-size=1920,1080") # 可以根據需要調整這個大小