教程:Python爬虫实例:采集微博博文|附视频
优采云 发布时间: 2022-11-09 23:18教程:Python爬虫实例:采集微博博文|附视频
这个案例解释了如何使用 Python 调用微博 API 来采集数据。
01
Python 将微博 API 称为数据实例采集
使用微博API获取博客文章主要涉及两个接口,即status/user_timeline/ids和statuses/show。前者用于获取用户发布的微博ID列表,后者是基于微博ID获取单个微博消息的内容,包括文字内容、图片、评论转发等。以下是这两个接口的详细说明。
(1)状态/user_timeline/ID
该接口的请求参数包括OAuth授权后获取的access_token和需要检索的微博用户ID,如表9-8所示,部分参数可选,使用默认值。
表9-8 状态/user_timeline/ID的请求参数
该接口仅返回最新的 5 条数据,即用户 uid 发布的微博 ID 列表。格式如下,以及状态中的记录列表。
{<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> "statuses": [<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> "3382905382185354",<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> "3382905252160340",<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> "3382905235630562",<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> ...<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> ],<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> "previous_cursor": 0, // 暂未支持<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> "next_cursor": 0, // 暂未支持<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" /> "total_number": 16<br style="box-sizing: border-box;font-size: inherit;color: inherit;line-height: inherit;overflow-wrap: inherit !important;word-break: inherit !important;" />}
(2)状态/显示
该接口的请求参数还包括OAuth授权后获取的access_token,另一个是微博ID,两者都是必需的,如表9-9所示。
表9-9 状态请求参数/显示
该接口返回微博的相关属性值,包括微博的创建时间和文字内容,如表9-10所示。
表9-10 状态/显示的返回字段
接下来,以statuses/user_timeline/ids接口为例,说明具体的调用和处理方法。
(1) 根据接口描述构造正确的 HTTP 请求。
阅读在线接口的说明,可以看到在 Get 模式下需要请求接口,所需参数access_token,返回格式为 json。所需的参数access_token从 OAuth 授权派生的,有关如何创建它们,请参阅参考书的第 9.2 节。
最新版本:批量采集各种群组邀请码-百度云论坛群组采集软件最新版
其实我发现百度云里面有个百度云论坛群,但是很多都需要邀请码什么的,然后就很难进了,不过要是有一批采集就好了各种群邀请码。,所以这个百度云论坛群采集软件可以直接提取里面的邀请码进入论坛。
百度云论坛群采集软件使用知识兔
先下载软件,直接打开
单击 采集 组的链接
也可以加入QQ群
软化后可以直接进入
注意事项知识兔
[1] 本软件为Easy Language编写,出现误报是正常的。听
[2] 建议开启影子模式或虚拟机使用该资源。听
[3] 本软件采集自网络,不得用于商业用途!听
点击下载
下载体验
点击下载