[問題] 如何用multiprocess抓API資料
各位前輩大家好
小弟是python 新手
目前在抓API資料遇到速度的問題
API是根據不同id吐資料出來
code如下
url = "http://123456789/"
id = "jimmy"
for id in ID:
response = requests.get(url+id)
info = response.json(encoding = "utf-8")
##save info
我的ID是個50萬筆的list,如果僅用一個跑的話要跑好幾天
最簡單的做法就是把ID切成好幾分,在開好幾個script同時跑
但是想請教各位高手們如何應用multiprocess 抓取API的資料?
讓抓取的速度在快一點
先謝謝各位了!
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 140.109.21.100
※ 文章網址: https://www.ptt.cc/bbs/Python/M.1483932740.A.DAA.html
推
01/09 12:06, , 1F
01/09 12:06, 1F
→
01/09 12:26, , 2F
01/09 12:26, 2F
→
01/09 12:39, , 3F
01/09 12:39, 3F