youtube后端是python吗_使用Python获取Youtube数据

1586010002-jmsa.png

I'm trying to learn how to analyze social media data available on the web and I'm starting with Youtube.

from apiclient.errors import HttpError

from outh2client.tools import argparser

from apiclient.discovery import build

import pandas as pd

DEVELOPER_KEY = "AIzaSyB_F1mCrDydEbGUosnZES-NW-mg1CaOyjI"

YOUTUBE_API_SERVICE_NAME = "youtube"

YOUTUBE_API_VERSION = "v3"

argparser.add_argument("--q", help="Search term", default="apple product")

argparser.add_argument("--max-results", help="Max results", default=50)

args = argparser.parse_args()

options = args

And I get this error.

ArgumentError Traceback (most recent call last)

in ()

----> 1 argparser.add_argument("--q", help="Search term", default="apple product")

2 argparser.add_argument("--max-results", help="Max results", default=50)

3 args = argparser.parse_args()

4 options = args

/usr/lib/python2.7/argparse.py in add_argument(self, *args, **kwargs)

1306 raise ValueError("length of metavar tuple does not match nargs")

1307

-> 1308 return self._add_action(action)

1309

1310 def add_argument_group(self, *args, **kwargs):

/usr/lib/python2.7/argparse.py in _add_action(self, action)

1680 def _add_action(self, action):

1681 if action.option_strings:

-> 1682 self._optionals._add_action(action)

1683 else:

1684 self._positionals._add_action(action)

/usr/lib/python2.7/argparse.py in _add_action(self, action)

1507

1508 def _add_action(self, action):

-> 1509 action = super(_ArgumentGroup, self)._add_action(action)

1510 self._group_actions.append(action)

1511 return action

/usr/lib/python2.7/argparse.py in _add_action(self, action)

1320 def _add_action(self, action):

1321 # resolve any conflicts

-> 1322 self._check_conflict(action)

1323

1324 # add to actions list

/usr/lib/python2.7/argparse.py in _check_conflict(self, action)

1458 if confl_optionals:

1459 conflict_handler = self._get_handler()

-> 1460 conflict_handler(action, confl_optionals)

1461

1462 def _handle_conflict_error(self, action, conflicting_actions):

/usr/lib/python2.7/argparse.py in _handle_conflict_error(self, action, conflicting_actions)

1465 for option_string, action

1466 in conflicting_actions])

-> 1467 raise ArgumentError(action, message % conflict_string)

1468

1469 def _handle_conflict_resolve(self, action, conflicting_actions):

ArgumentError: argument --q: conflicting option string(s): --q

I'm using a tutorial for this but I get an error.

解决方案

It looks like the parser that you import

from outh2client.tools import argparser

already has defined a -q argument. You can check that by looking at its code, or by doing a argparser.print_help() (before adding anything yourself).

So the simplest solution is to choose another name for your argument.

The relevant docs are

found by looking up 'conflict' on that page.

The parser defined on https://github.com/google/oauth2client/blob/master/oauth2client/tools.py does not have a -q argument. Is this your source? I assume the missing a is a spelling error.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值