Python Requests Module
ဥပမာ
ဝဘ်စာမျက်နှာသို့ တောင်းဆိုချက်တစ်ခုပြုလုပ်ပြီး တုံ့ပြန်ချက်စာသားကို ပရင့်ထုတ်ပါ-
import requests
x = requests.get('https://w3schools.com/python/demopage.htm')
print(x.text)
အဓိပ္ပါယ်နှင့် အသုံးပြုမှု
မော် requests
ဂျူးသည် သင့်အား Python ကို အသုံးပြု၍ HTTP တောင်းဆိုမှုများကို ပေးပို့ရန် ခွင့်ပြုသည်။
HTTP တောင်းဆိုချက်သည် တုံ့ပြန်မှုဒေတာအားလုံး (အကြောင်းအရာ၊ ကုဒ်နံပါတ်၊ အခြေအနေ၊ စသည်) ဖြင့် တုံ့ပြန်မှုအရာဝတ္တု ကို ပြန်ပေးသည်။
Requests Module ကို ဒေါင်းလုဒ်လုပ်ပြီး ထည့်သွင်းပါ။
PIP တည်နေရာသို့ သင်၏ အမိန့်ပေးစာကြောင်းကို လမ်းညွှန်ပြီး အောက်ပါတို့ကို ရိုက်ထည့်ပါ-
C:\Users\Your Name\AppData\Local\Programs\Python\Python36-32\Scripts>pip install requests
အထားအသို
requests.methodname(params)
နည်းလမ်းများ
Method | Description |
---|---|
delete(url, args) | Sends a DELETE request to the specified url |
get(url, params, args) | Sends a GET request to the specified url |
head(url, args) | Sends a HEAD request to the specified url |
patch(url, data, args) | Sends a PATCH request to the specified url |
post(url, data, json, args) | Sends a POST request to the specified url |
put(url, data, args) | Sends a PUT request to the specified url |
request(method, url, args) | Sends a request of the specified method to the specified url |