06Python爬虫:发送post请求

实现代码:

import requests
import json
 
url = "http://218.241.146.94:8989/translate/trans"
payload = {"from": "zh", "to": "ww", "src_text": "你好!"}
for i in range(3):
    response = requests.post(url, json=payload)
    htm_str = response.content.decode()
    data = json.loads(htm_str)["responseData"]
    print(data.replace(" ", "").replace(" <br/>", ""))

 

posted @ 2019-09-15 14:13  Jumpkin1122  阅读(278)  评论(2编辑  收藏  举报