注册 登录
编程论坛 Python论坛

爬虫问题咨询,求大家帮忙看看为什么

yangzexuan 发布于 2019-04-25 10:39, 1304 次点击
# encoding: utf-8
from __future__ import unicode_literals
import time
import sys
import pymongo
import numpy as np
import pandas as pd
import pyecharts
import datetime
import requests
# from bitmex_8hourkline_fundingrate import *

def get_kline_data(minute='1d', symbol='BTCUSD', startTime=""):
    headers = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/73.0.3683.103 Safari/537.36'}

    print(startTime)
    try:
        if startTime != "":
            s = requests.session()#关闭多余的连接
            s.keep_alive = False#关闭多余的连接
            requests.adapters.DEFAULT_RETRIES = 5 #增加重试连接次数
            response = requests.get(
                "https://www. % (
                minute, symbol, startTime), headers=headers)
        else:
            s = requests.session()
            s.keep_alive = False
            requests.adapters.DEFAULT_RETRIES = 5  # 增加重试连接次数
            response = requests.get(
                "https://www. % (
                minute, symbol), headers=headers)
        r = response.json()
        return r
    except Exception as e:
        print(e)
        return None
print(get_kline_data(minute='1d', symbol='XBTUSD', startTime=""))

我想爬取bitstamp交易所比特币的历史K线数据,这个报错了,
"C:\Program Files\Python37\python.exe" E:/pycharm/test01/zijinfeilv.py

not all arguments converted during string formatting
None

Process finished with exit code 0

请问这个怎么修改
1 回复
#2
wp2319572019-04-25 10:56
目测 这个不能对吧

 response = requests.get(
                "https://www. % (
                minute, symbol, startTime), headers=headers)

%后面有3个变量  前面没有占位啊
1