我正在尝试向 API 发出大量 GET 请求(在 1000 到 2000 之间)。到目前为止,它花费了超过 5 分钟,MySQL 服务器刚刚关闭了我的连接。
我想在一分钟内完成。应该可以吧?
这是我目前所拥有的:
def get_data(devices):
for dev in devices: #array containing around 1000 devices
model = str(dev[0])
brand = str(dev[1])
model = model.replace(" ", "%20")
brand = brand.replace(" ","%20")
os = urllib2.urlopen('https://api.com/getData?&brand=' + brand + '&model='+ model).read()
xmldoc = minidom.parseString(os)
for element in xmldoc.getElementsByTagName('name'):
print (element.firstChild.nodeValue)
最佳答案
关于Python - 1000-2000 个 API 请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29879390/