ถ้าตรวจเว็บ url ภาษา อังกฤษ จะไม่มีปัญหาครับ แต่ถ้าตรวจ url ที่เป็นภาษาไทย
โปรแกรมจะเเจ้ง error status 403 ครับ ทั้งๆที่สามารถเข้า url ได้ปกติครับ
code ที่ใช้เช็คครับ
โค้ด: เลือกทั้งหมด
#!/usr/bin/python
# -*- coding: utf-8 -*-
#method1
import requests
from requests.exceptions import HTTPError
#method2
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
import configparser
import time
import email
import smtplib
con = None
config = configparser.ConfigParser()
config.read('admin.conf')
SMTP=config['options']['SMTP']
ports=config['options']['ports']
user = config['options']['user']
password = config['options']['password']
sender = config['options']['sender']
recipient = config['options']['recipient_email']
r_link= open('check_link.txt',"r")
plt = open("plateformEmail.txt")
plt = plt.read()
save_link = []
check = []
n = 0
print("Start_test:", s_t)
for line in r_link:
print("link:",n)
n += 1
line=line.lstrip()
try:
response = urlopen(line)
except HTTPError as e:
print('The server couldn\'t fulfill the request.',line)
print('Error code: ', e.code)
e.code=str(e.code)
save_link.append(str(n)+" "+'The server couldn\'t fulfill the request '+'('+e.code+')'+' :'+line)
check.append("N")
except URLError as e:
print('We failed to reach a server.',line)
print('Reason: ', e.reason)
save_link.append(str(n) + " " + 'We failed to reach a server. :' + line)
check.append("N")
else:
print('Website is working fine',line)
save_link.append(str(n) + " " + 'Website is working fine. :' + line)
check.append("Y")
1 https://www.mindphp.com/%E0%B8%9A%E0%B8 ... nants.html
2 https://www.mindphp.com/%E0%B8%9A%E0%B8 ... nants.html
ซึ่งเมื่อนำลิงค์ไป monitor โปรแกรม แจ้งมาว่า error code 403 ครับ
ไม่ทราบว่าเกิดความผิดพลาดจากอะไรครับlink: 0
The server couldn't fulfill the request. https://www.ideagital.com/savepong/%E0% ... 4-pomodoro
Error code: 403
link: 1
The server couldn't fulfill the request. https://thaihealthlifestyle.com/article ... %E0%B8%99/
Error code: 403