python爬虫的一些简单尝试

本文介绍了使用Python进行网络爬虫的实践,包括获取B站番剧列表和统计B站在线人数两个部分。通过运行代码,展示了爬虫的基本流程与数据获取效果。
摘要由CSDN通过智能技术生成

①获取B站番剧列表

#-*- coding: UTF-8 -*-
import requests
import json
import openpyxl
wb=openpyxl.Workbook()
sheet=wb.get_active_sheet()
sheet['A1']='season_id'
sheet['B1']='title'
sheet['C1']='total_count'
sheet['D1']='favorites'
index=2
for i in range(1,10):
    url='https://bangumi.bilibili.com/web_api/season/index_global?page={}&page_size=20&version=0&is_finish=0&start_year=2017&tag_id=&index_type=1&index_sort=0&quarter=0'.format(i)
    res= requests.get(url)
    content=res.content
    myjson=json.loads(content)
    for j in range(len(myjson['result']['list'])):
            sheet['A{}'.format(index)] = myjson['result']['list'][j]['season_id']
            sheet['B{}'.format(index)] = myjson['result
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值