GithubHelp home page GithubHelp logo

wpspider's Introduction

利用python-wordpress-xmlrpc库整合Python爬虫,实现自动化发布文章到自己的wordpress

新版本的 多站点适配 请查看 https://github.com/MagicDu/mywpspider

环境说明

  • WordPress 3.4+ OR WordPress 3.0-3.3 with the XML-RPC Modernization Plugin.
  • Python 3.x
  • Ubunutu 16.04
  • install python-wordpress-xmlrpc
    sudo pip3 install python-wordpress-xmlrpc
  • 只是以某单一的网站为例,抓取其他网站,请自行重写get_news(link),get_urls(url,n)函数
  • 保存文章标题到本地,需要在write_file(str_title)指定你的文件路径
  • 出现异常会发送邮件,需要你指定发送者邮箱的属性以及接收者的邮箱
  • crontab自动执行脚本,需要Python3.5 安装python-crontab,仅适用于linux,windows和Mac请自行写自动执行脚本 运行脚本前,请指定将要运行的爬虫目录,以及运行时间,具体参考crontab的说明
  • sh脚本适用于crontab无法直接执行python脚本的问题,需要用crontab执行sh脚本,sh脚本调用python脚本
    sudo pip3 install python-crontab
  • 功能尚未完善,今后会继续添加

版本说明

2017-02-26 v1.0.0

1.实现了抓取单个文章的内容发布到wordpress

2.提取了文章标题,标签,内容,分类

2017-02-27 v1.0.1

1.增加‘获取最新的新闻链接列表’的函数 get_urls(url,n)

2.遍历获取的新链接列表发布文章到wordpress,文章数量可以通过参数n指定,默认值为1

3.增加发布下一篇文章之前,休眠5秒

2017-02-28 v1.0.2

1.修复标签为空时无法发布文章的bug

2.增加将文章标题保存到本地文件的功能 write_file(str_title)

3.增加了crontab 自动执行脚本 “createCronTab.py”

2017-03-01 v1.0.3

1.增加wp.sh脚本,如果服务器上的crontab直接执行python脚本出错,需要用crontab调用sh脚本,sh脚本调用python脚本(主要是crontab执行环境变量与系统环境变量存在差异)

2017-03-03 v1.0.4

1.增加部分异常处理

2.出现异常自动发送电子邮件

2017-03-04 v1.0.5

1.增加特征图片的处理,为文章设置特征图片

  (ps:此功能涉及下载上传图片,可以阉割掉,在wordpress端自行指定特征图片)

2017-03-11 v1.1.0

1.urllib改用 requests库

2.增加请求头处理,多useragent 适配,防止被封IP

Bug说明

单一性

1.目前处理的只是一个网站 金融之家的内容作为示例

2.获取的文章内容还未经过提取处理,只是字符串发布

TodoList

爬虫适应性提升

1.多网站适应

wpspider's People

Contributors

magicdu avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.