a spider bot (scrawler) by python, using selenium and chrome driver
Project description
spider_bot
爬虫机器人。
请注意,本 repo 并未提供有效的 xpaths 语法,目前配置文件中的 xpaths 仅作示例。
如何部署?
1、拷贝源码
git clone https://github.com/liujuanjuan1984/spider_bot.git
cd spider_bot
2、安装依赖
pip install spider_bot
pip install selenium
安装与 chrome 版本一致的 chromedriver 并把可执行文件放在系统的 PATH 目录下
3、修改配置
参考 config_private_sample.py 创建 config_private.py 文件并更新相关字段
4、如何运行?
4.1 首次初始化 bot 时,传入 init=True
用于生成 database,成功执行将在当前目录下 生成 spider_bot.db 文件。
from spider_bot import SpiderBot
bot = SpiderBot(init=True)
4.2 添加 users,如果确定爬取这些用户,则传入 True,待确认就传入 None
urls = ["https://example.com/user_a_homepage", "https://example.com/user_b_homepage"]
bot.add_users(working_status=True, *urls)
4.3 根据需要爬取内容
bot.get_profiles()
bot.get_new_posturls()
bot.get_history_posturls(1, 9)
bot.get_posts()
历史内容和 profile 只需要爬取一遍,如果有遗漏,可重复爬取;
最新内容则需要持续爬取。
代码格式化与检查
isort .
black .
pylint spider_bot > pylint_spider_bot.log
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
spiderbot-0.1.0.tar.gz
(21.4 kB
view hashes)
Built Distribution
spiderbot-0.1.0-py3-none-any.whl
(22.7 kB
view hashes)
Close
Hashes for spiderbot-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | d9dc629ac570916dc745fd34dea146a1b7f38e68308d10823fb9bb46ea9263ef |
|
MD5 | b914282d44b5c183f0030ea5ae1dc99a |
|
BLAKE2b-256 | 5da9f9663d72fad06d3922a99f796263d8f65c06530188691e56303d4e0de70f |