Python Interface Automation test three: code to send HTTP requests

Source: Internet
Author: User

GET Request:

1. Get request (no parameters):

2. Get request (with parameters):

Interface Address: HTTP://JAPI.JUHE.CN/QQEVALUATE/QQ

Return format: JSON

Request method: Get Post

Sample request: Http://japi.juhe.cn/qqevaluate/qq?key= the appkey&qq=295424589 you requested

Interface Note: According to the parameters of the QQ number and the AppKey you applied to test QQ inauspiciousness

Request parameter description (enter parameter):

Name Required type description

Key is the string you requested for the APPKEY:8DBEE1FCD8627FB6699BCE7B986ADC45

QQ is the string needs to test QQ number: 907728701

2.1, the URL of the way to pass the parameter:

url = ' http://japi.juhe.cn/qqevaluate/qq?key= 8dbee1fcd8627fb6699bce7b986adc45&qq=907728701 '

2.2, in the form of a dictionary to pass the parameter:

url = ' HTTP://JAPI.JUHE.CN/QQEVALUATE/QQ '

Par = {

' Key ': ' 8dbee1fcd8627fb6699bce7b986adc45 ',

' QQ ': ' 907728701 '

}

R = Requests.get (Url,params=par) #发送get请求

POST request:

1. Post request (no parameters):

url = ' HTTP://JAPI.JUHE.CN/QQEVALUATE/QQ '

r = Requests.post (URL) #发送post请求

Print (R.status_code) #打印状态码

Print (r.headers) #打印返回的报头 (head)

Print (R.text) #查看返回结果的文本形式 (body part)

2. Post request (with parameters):

2.1, the URL of the way to pass the parameter:

url = ' http://japi.juhe.cn/qqevaluate/qq?key= 8dbee1fcd8627fb6699bce7b986adc45&qq=907728701 '

r = Requests.post (URL) #发送post请求

2.2, in the form of a dictionary to pass the parameter:

url = ' HTTP://JAPI.JUHE.CN/QQEVALUATE/QQ '

Par = {

' Key ': ' 8dbee1fcd8627fb6699bce7b986adc45 ',

' QQ ': ' 907728701 '

}

R = Requests.post (Url,params=par) #发送get请求

Python Interface Automation test three: code to send HTTP requests

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.