python 3.5 ครับ
ติด raise URLError(err) ครับ
Moderator: mindphp, ผู้ดูแลกระดาน
- chakirin.bfds
- PHP Super Hero Member
- โพสต์: 783
- ลงทะเบียนเมื่อ: 22/12/2020 10:19 am
- thatsawan
- PHP VIP Members
- โพสต์: 28508
- ลงทะเบียนเมื่อ: 31/03/2014 10:02 am
- ติดต่อ:
Re: ติด raise URLError(err) ครับ
โค้ด: เลือกทั้งหมด
from urllib.request import Request, urlopen
from urllib.error import URLError, HTTPError
req = Request("http://google4.com")
try:
response = urlopen(req)
except HTTPError as e:
print('The server couldn\'t fulfill the request.')
print('Error code: ', e.code)
except URLError as e:
print('We failed to reach a server.')
print('Reason: ', e.reason)
else:
print ('Website is working fine')
โค้ด: เลือกทั้งหมด
The server couldn't fulfill the request.
Error code: 403
https://stackoverflow.com/questions/194 ... via-python
- chakirin.bfds
- PHP Super Hero Member
- โพสต์: 783
- ลงทะเบียนเมื่อ: 22/12/2020 10:19 am
Re: ติด raise URLError(err) ครับ
ได้เเล้วครับ ขอบคุณครับthatsawan เขียน: ↑28/01/2021 2:03 pmผลโค้ด: เลือกทั้งหมด
from urllib.request import Request, urlopen from urllib.error import URLError, HTTPError req = Request("http://google4.com") try: response = urlopen(req) except HTTPError as e: print('The server couldn\'t fulfill the request.') print('Error code: ', e.code) except URLError as e: print('We failed to reach a server.') print('Reason: ', e.reason) else: print ('Website is working fine')
อ้างอิงโค้ด: เลือกทั้งหมด
The server couldn't fulfill the request. Error code: 403
https://stackoverflow.com/questions/194 ... via-python
ผู้ใช้งานขณะนี้
สมาชิกกำลังดูบอร์ดนี้: ไม่มีสมาชิกใหม่ และบุคลทั่วไป 51