app.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:oabot 作者: dissemin 项目源码 文件源码
def edit_wiki_page(page_name, content, summary=None):
    access_token = flask.session.get('access_token', None)
    auth = OAuth1(
        app.config['CONSUMER_KEY'],
        app.config['CONSUMER_SECRET'],
        access_token['key'],
        access_token['secret'])

    # Get token
    r = requests.get('https://en.wikipedia.org/w/api.php', params={
    'action':'query',
    'meta':'tokens',
        'format': 'json',
    }, auth=auth)
    r.raise_for_status()
    token = r.json()['query']['tokens']['csrftoken']

    r = requests.post('https://en.wikipedia.org/w/api.php', data={
    'action':'edit',
        'title': page_name,
    'text': content,
        'summary': summary,
        'format': 'json',
        'token': token,
        'watchlist': 'nochange',
    }, auth=auth)
    r.raise_for_status()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号