การเรียกใช้ web service นั้นจะต้องทำการทดสอบโดยใช้คำสั่ง cURL ทดสอบ แตถ้าในฝั่งของภาษา Python จะมี library ตัวหนึ่งที่ทำการทำการเรียกใช้ wed service นำมาใช้งานรูปแบบการทำการงานก็คือ ทำการ request ในฝั่ง client แล้วส่งไปยัง server แล้วทางฝั่ง server ก็ทำการ response สิ่งที่ client ได้ request มาส่งกลับให้ส่วนนี้ก็ทำงานในรูปแบบของ web service ในรูปแบบคำสั่งก็มีดังนี้
โค้ด: เลือกทั้งหมด
import requests
r = requests.get(' [URL ของ web service] ')
โค้ด: เลือกทั้งหมด
import requests
r = requests.get('http://127.0.0.1:5555/view/1/www.google.com', auth=('m090','m090'))
with open('htmltopdf.pdf', 'wb') as f:
f.write(r.content)
print r
อ้างอิง
https://2.python-requests.org/en/master/
https://pypi.org/project/requests/
https://www.pythonforbeginners.com/requests/using-requests-in-python