Update 酒店源.py

This commit is contained in:
frxz751113
2024-08-29 21:05:12 +08:00
committed by GitHub
parent 5ab3595938
commit 03a44449ca
+11 -6
View File
@@ -53,8 +53,8 @@ def is_url_accessible(url):
response = requests.get(url, timeout=1)
if 200 <= response.status_code <= 401:
return url
except requests.exceptions.RequestException:
pass
except requests.exceptions.RequestException as e:
print(f"Error checking {url}: {e}")
return None
@@ -66,6 +66,7 @@ for url in urls:
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
driver = webdriver.Chrome(options=chrome_options)
try:
# 使用 WebDriver 访问网页
driver.get(url)
time.sleep(10)
@@ -132,10 +133,14 @@ for url in urls:
urld = (f"{urls[0]}//{urls[2]}")
with open('iptv.txt', 'a', encoding='utf-8') as outfile:
outfile.write(f"{name},{urld}\n")
except:
pass
except:
pass
except Exception as e:
print(f"Error processing line in JSON: {e}")
except Exception as e:
print(f"Error fetching JSON from {json_url}: {e}")
except Exception as e:
print(f"Error with URL {url}: {e}")
print("频道列表文件 iptv.txt 获取完成!")