Update 酒店源.py
This commit is contained in:
@@ -53,8 +53,8 @@ def is_url_accessible(url):
|
|||||||
response = requests.get(url, timeout=1)
|
response = requests.get(url, timeout=1)
|
||||||
if 200 <= response.status_code <= 401:
|
if 200 <= response.status_code <= 401:
|
||||||
return url
|
return url
|
||||||
except requests.exceptions.RequestException:
|
except requests.exceptions.RequestException as e:
|
||||||
pass
|
print(f"Error checking {url}: {e}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
@@ -66,6 +66,7 @@ for url in urls:
|
|||||||
chrome_options.add_argument('--no-sandbox')
|
chrome_options.add_argument('--no-sandbox')
|
||||||
chrome_options.add_argument('--disable-dev-shm-usage')
|
chrome_options.add_argument('--disable-dev-shm-usage')
|
||||||
driver = webdriver.Chrome(options=chrome_options)
|
driver = webdriver.Chrome(options=chrome_options)
|
||||||
|
try:
|
||||||
# 使用 WebDriver 访问网页
|
# 使用 WebDriver 访问网页
|
||||||
driver.get(url)
|
driver.get(url)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
@@ -132,10 +133,14 @@ for url in urls:
|
|||||||
urld = (f"{urls[0]}//{urls[2]}")
|
urld = (f"{urls[0]}//{urls[2]}")
|
||||||
with open('iptv.txt', 'a', encoding='utf-8') as outfile:
|
with open('iptv.txt', 'a', encoding='utf-8') as outfile:
|
||||||
outfile.write(f"{name},{urld}\n")
|
outfile.write(f"{name},{urld}\n")
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
print(f"Error processing line in JSON: {e}")
|
||||||
except:
|
except Exception as e:
|
||||||
pass
|
print(f"Error fetching JSON from {json_url}: {e}")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"Error with URL {url}: {e}")
|
||||||
|
|
||||||
print("频道列表文件 iptv.txt 获取完成!")
|
print("频道列表文件 iptv.txt 获取完成!")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user