Giter VIP home page Giter VIP logo

bupt-news's Introduction

BUPT-信息门户爬虫

爬取北京邮电大学信息门户的通知,并通过微信订阅号进行推送

使用说明

1、下载代码后,安装需要的库(后续会上传requirement.txt),并配置好edge驱动器,注意要和浏览器的版本一致。(chrome和firfox找到版本一致的驱动器比较麻烦)

2、填写代码中的username和password。注意:我这里登录vpn和信息门户都是用的一样的密码,但如果你两个网站用的密码不一样,需要自己修改一下代码,给两个登录函数分别传入相应的密码。(由于我一开始就把所有校内网站的密码改为了一样的,所有我也忘了这俩网站的账号是不是互通的)

3、在微信公众平台申请微信订阅号,申请网站为:https://mp.weixin.qq.com/debug/cgi-bin/sandboxinfo?action=showinfo&t=sandbox/index,申请后马上就能用,记得扫码关注订阅号。

4、在微信公众平台添加模板消息,模板标题可以随便填,模板内容必须设置为:通知:{{title1.DATA}} :{{title2.DATA}} :{{title3.DATA}} 发布部门:{{author.DATA}} 发布时间:{{time.DATA}}

5、将微信公众平台appID、appSecret复制到代码里的变量对应处,模板ID(template_id)也复制到对应处,这三个变量都在craw_and_send()函数里。

6、然后应该就可以跑代码了,接下来应该会在微信收到订阅号的消息。

1、由于模板消息每个字段都有字数限制,所以无法完整显示通知的标题,所以我把标题分成了三段。这样看起来很奇怪,但也没办法,有待解决。

2、我是把代码运行在云服务器上的,阿里云有学生免费服务器,可以用7个月。如果你想在本地跑,建议设置个开机自启什么的。以及,在有校园网环境,或者使用了atrust的情况下,也可以不用登录vpn(以至于代码可以有很大改进),后续我会发一版有校园网环境的代码,会简陋一些,但是因为可以用requests库,代码效率会高一些。

3、atrust没有linux版本,也没有windows server版本,这就是我要登录网页版的vpn的原因。

4、配置好浏览器驱动器后,selenium库可能还是无法正常跑,可以在代码里加上浏览器驱动器的路径,即driver_path变量。

如有问题可以发issues

bupt-news's People

Contributors

saltedfish555 avatar

Stargazers

 avatar

Watchers

 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.