我想使用具有多个参数的 URL 进行 curl 调用。我已经列出了下面的代码。例如,“curl -d @filter”是否有等效选项,或者我是否对参数进行 URL 编码?
SER = foobar
PASS = XXX
STREAM_URL = "http://status.dummy.com/status.json?userId=12&page=1"
class Client:
def __init__(self):
self.buffer = ""
self.conn = pycurl.Curl()
self.conn.setopt(pycurl.USERPWD, "%s:%s" % (USER,PASS))
self.conn.setopt(pycurl.URL, STREAM_URL)
self.conn.setopt(pycurl.WRITEFUNCTION, self.on_receive)
self.conn.perform()
def on_receive(self,data):
self.buffer += data