亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何找到具有特定 URL 的 requests.post 函數所需的數據參數?

如何找到具有特定 URL 的 requests.post 函數所需的數據參數?

慕的地8271018 2022-12-20 16:22:55
我想使用請求庫向特定網頁http://latex2png.com/api/convert發出請求,以便將一些乳膠轉換為 PNG 圖像。但是,我不確定該網站接受哪些數據參數。有什么方法可以使用requests庫來查看需要滿足哪些參數?我試過跑步options = {    "auth": {"user": "guest", "password": "guest"},    "latex": '$a^3$',    "resolution": 900,    "color": "969696",}r = requests.post('http://latex2png.com/api/convert')print(r.content)但我明白了b'{"result-message":"no request","result-code":-2}'。沒有關于此特定 API 和網站的文檔或在線幫助。
查看完整描述

1 回答

?
白板的微信

TA貢獻1883條經驗 獲得超3個贊

那是因為你發帖的方式不對,試試這個:


import requests


headers = {

    "Content-type": "application/x-www-form-urlencoded",

}


data = {

    "auth": {

        "user": "guest",

        "password": "guest"

    },

    "latex": "a^3",

    "resolution": 600,

    "color": "969696"

}


r = requests.post('http://latex2png.com/api/convert', headers=headers, json=data) # the right way to send POST requests

print(r.json())  # print the json

image_url = "http://latex2png.com" + r.json()['url']

r = requests.get(image_url)

with open("download.png", "wb+") as f: # download it.

    f.write(r.content)


查看完整回答
反對 回復 2022-12-20
  • 1 回答
  • 0 關注
  • 123 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號