Giter VIP home page Giter VIP logo

Comments (3)

chyroc avatar chyroc commented on May 18, 2024

在改。。。挺简单的。。

from wechatsogou.

chyroc avatar chyroc commented on May 18, 2024

具体是哪个情景下,会有需求呢

from wechatsogou.

crisfan avatar crisfan commented on May 18, 2024

答:用框架最大的好处在我看来无外乎在于后续需要修改代码的话,我们能很快知道在框架的那个模块里去修改(毕竟里面已经变相规定每个模块干什么功能),同时框架很多功能我们也不用去实现了,比如多线线程,设置下载速度(配置参数就OK)
其实我现在想在框架的基础上实现每5个小时定时抓取各个分类下最新的文章(判重好像只能通过标题是否重复了吧!)
import pymongo
import readability
import re
from lxml import etree

client = pymongo.MongoClient()
db = client.sougou

articles_single = []
page = 0
article_urls = wechats.get_recent_article_url_by_index_all()

for url in article_urls:
html_text = wechats.get_gzh_message(url=url)
try:
article_content = readability.Readability(html_text, url).content
except RuntimeError as e:
article_content = None
article_title = re.search('<title>(.*?)</title>', html_text).group(0)
html_string = etree.HTML(html_text)
try:
article_date = html_string.xpath('//em[@id="post-date"]/text()')[0]
except IndexError as e:
article_date = None
db.wechats.insert({'title': article_title, 'content': article_content, 'date': article_date})

但是发现好像就是上面简单的程序放在框架里很蛋疼,无法实现。

from wechatsogou.

Related Issues (20)

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.