python3计算生态之从Web解析到网络空间(网络爬虫、Web网站/应用开发)

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34195441/article/details/88615448

1、Python库之网络爬虫

Requests:最友好的网络爬虫功能库

-提供了简单易用的类HTTP协议网络爬虫功能,支持连接池、SSL、Cookies、HTTP(S)代理等

-Python最主要的页面级网络爬虫功能库

-网址:http://www.python-requests.org/

import requests
r = requests.get('http://api.github.com/user',auth=('user','pass'))
r.status_code
r.headers['content-type']
r.encoding
r.text

Scrapy:优秀的网络爬虫框架、Python数据分析高层次应用库

-提供了构建网络爬虫系统的框架功能,功能半成品。支持批量和定时网页爬取、提供数据处理流程等

-Python最主要且最专业的网络爬虫框架

-网址:https://scrapy.org

Pyspider:强大的Web页面爬取系统

-提供了完整的网页爬取系统构建功能,支持数据库后端、消息队列 、优先级、分布式架构等

扫描二维码关注公众号,回复: 5564283 查看本文章

-Python重要的网络爬虫类第三方库

-网址:http://docs.pyspider.org

Beautiful Soup:HTML和XML的解析库

-提供了解析HTML和XML等Web信息的功能,又名beautifulsoup4或bs4,可以加载多种解析引擎

-常与网络爬虫库搭配使用,如Scrapy、requests等

-https://www.crummy.com/software/BrautifulSoup/bs4

Re:正则表达式解析和处理功能库

-提供了定义和解析正则表达式的一批通用功能,可用于各类场景,包括定点的Web信息提取

-Python最主要的标准库之一,无需安装

字符串:r'\d{3}-\d{8}|\d{4}-\d{7}'
围绕字符串进行信息查找和匹配的语句:
re.search()
re.match()
re.findall()
re.split()
re.finditer()
re.sub()

Python-Goose:提取文章类型Web页面的功能库

-提供了对Web页面中文章信息/视频等元素的提取功能,针对特定类型Web页面,应用覆盖面较广

-Python最主要的Web信息提取库

-https://github.com/grangier/python-goose

from goose import Goose
url = 'http://www.elmundo.es/elmundo/2012/10/28/espana/1351388909.html'
g = Goose({'use_meta_language':False,'target_language':'es'})
article = g.extract(url=url)
article.cleaned_text[:150]

2、Python库之Web网站开发

Django:最流行的Web应用框架

-提供了构建Web系统的基本应用框架。MTV模式:模型(model)、模板(Template)、视图(Views)

-Python最重要的Web应用框架,略微复杂的应用框架

-http://www.djangoproject.com

Pyramid:规模适中的Web应用框架

-提供了简单方便构建Web系统的应用框架,不大不小,规模适中,适合快速构建并适度扩展类应用

-Python产品 级Web应用框架,起步简单可扩展性好,比较稳定

-http://trypyramid.com/

from wsgiref.simple_server import make_server
from pyramid.config import Configurator
from pyramid.response import Response
def hello_world(request):
    return Response('Hello World!')
if _name_=='_main_':
    with Configurator() as config:
        config.add_route('hello','/')
        config.add_view(hello_world,route_name='hello')
        app = config.make_wsgi_app()
    server = make_server('0.0.0.0',6543,app)
    server.serve_forever()

Flask:Web应用开发微框架

-提供了最简单构建Web系统的应用框架。特点是:简单、规模小、快速

-Django > Pyramid > Flask好

-http://flask.pocoo.org

from flask import Flask
app = Flask(_name_)
@app.route('/')
def hello_world():
    return 'Hello World!'

3、Python库之网络应用开发

WeRoBot:微信公众号开发框架

-提供了解析微信服务器消息及反馈消息的功能

-建立微信机器人的重要技术手段

-https://github.com/offu/WeRoBot

import werobot
robot = werobot.WeRoBot(token='tokenhere')
@robot.handler
def hello(message):        #对微信每个消息反馈一个hello world
    return 'Hello World'

aip:百度AI开放平台接口

-提供了访问百度AI服务的Python功能接口

-语音、人脸、OCR、NLP、知识图谱、图像搜索等领域

-Python百度AI应用的最主要方式

-https://github.com/Baidu-AIP/python-sdk

MyQR:二维码生成第三方库

-提供了生成二维码的系列功能,基本二维码、艺术二维码和动态二维码

-https://github.com/sylnsfar/qrcode

猜你喜欢

转载自blog.csdn.net/qq_34195441/article/details/88615448