Git Product home page Git Product logo

boddy / baiduspider Goto Github PK

View Code? Open in Web Editor NEW

This project forked from baiduspider/baiduspider

0.0 1.0 0.0 44.81 MB

BaiduSpider,一个爬取百度搜索结果的爬虫,目前支持百度网页搜索,百度图片搜索,百度知道搜索,百度视频搜索,百度资讯搜索,百度文库搜索,百度经验搜索和百度百科搜索。

Home Page: https://baiduspider.github.io

License: MIT License

Python 100.00%

baiduspider's Introduction

BaiduSpider

BaiduSpider


BaiduSpider,一个爬取百度的利器


made-with-python GitHub GitHub Repo stars GitHub forks build status downloads

BaiduSpider是一个爬取百度搜索结果的Python爬虫,目前支持百度网页搜索,百度图片搜索,百度知道搜索,百度视频搜索,百度资讯搜索,百度文库搜索,百度经验搜索和百度百科搜索。


安装


BaiduSpider现已发布PyPI包,可以使用pip安装:

$ pip install baiduspider

或者从GitHub直接clone:

$ git clone https://github.com/BaiduSpider/BaiduSpider.git

# ...

$ python setup.py install

提示

BaiduSpider目前仅支持Python 3.6+,暂不支持Python 2.x


快速上手


BaiduSpider提供简易的,人性化的API,可通过实例化BaiduSpider对象后调用。例如,我想要使用网页搜索函数查询有关Python的信息:

# 导入BaiduSpider
from baiduspider import BaiduSpider
from pprint import pprint

# 实例化BaiduSpider
spider = BaiduSpider()

# 搜索网页
pprint(spider.search_web(query='Python'))

获得的搜索结果将类似下面的这个Python字典结果:

{'results': [{'result': 100000000, 'type': 'total'},
             {'results': ['0基础学python有多难',
                          'python自学行吗',
                          '学python要多久',
                          'python手机版',
                          'python有什么用',
                          '财务有必要学python吗',
                          'python为什么叫爬虫',
                          'python处理excel的优势',
                          'python自学免费教程'],
              'type': 'related'},
             {'result': {'cover': None,
                         'cover-type': None,
                         'des': 'Python是一种跨平台的计算机程序设计语言。 '
                                '是一个高层次的结合了解释性、编译性、互动性和面向对象的脚本语言。最初被设计用于编写自动化脚本(shell),随着版本的不断更新和语言新功能的添加,越多被用于独立的、大型项目的开发。',
                         'title': 'Python(计算机程序设计语言) - 百度百科',
                         'url': 'http://www.baidu.com/link?url=2z_Q_urbKikP4py4Y9tlMImyT090fjjaKi1gi4Z6bjvk1lU8MqYHewJTumd9YEpC5Jusis_8nqlTKsJgEMcRUa'},
              'type': 'baike'},
             {'des': 'The official home of the Python Programming Language... '
                     '# Python 3: Simple output (with Unicode) >>> '
                     'print("Hello, I\'m Python!") Hello, I\'m Python!',
              'origin': 'www.python.org/',
              'time': None,
              'title': 'Welcome to Python.org',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=NC7GXkMtnZ9t8csmbawkvfp2QbDaaMHleael-qkCOtlSy_kfPsT8ARljUiIVOH2L'},
             {'des': 'The official home of the Python Programming Language',
              'origin': 'www.python.org/getit',
              'time': None,
              'title': 'Download Python | Python.org',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=AKBkNZv2L7600dOvqeylKK0fSRJJboDgjf7xGPuZfx2giBnXAiukP5ch7Tb619zC'},
             {'des': 'Python(英国发音:/ˈpaɪθən/ 美国发音:/ˈpaɪθɑːn/), '
                     '是一种面向对象的解释型计算机程序设计语言,由荷兰人Guido van Rossum于1989年发明,第...',
              'origin': '知乎',
              'time': None,
              'title': 'Python - 知乎',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=xxKNKxpUHwEvoPt7OlqXceI0jTqTgvkJr0cncYDUPVNpYB397k-mbLlMOrw4IhNa'},
             {'des': 'Python 基础教程 Python 是一种解释型、面向对象、动态数据类型的高级程序设计语言。 Python 由 '
                     'Guido van Rossum 于 1989 年底发明,第一个公开发行版发行于 1991...',
              'origin': 'www.runoob.com/python/python-t...',
              'time': '2020年1月1日',
              'title': 'Python 基础教程 | 菜鸟教程',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=ShmleIIBtIEfujCO1Wqh3PrOab_VrP87gN9GkEDGwQSj9OJ27Hst5NRomZtDRaxI7-WWSGLJ0-olY7Gt5merVK'},
             {'des': '在Python 中,* 和 ** 具有语法多义性,具体来说是有三类用法。1. 算数运算* 代表乘法** '
                     '代表乘方>>> 2 * 510>>> 2 ** 5322...',
              'origin': 'CSDN技术社区',
              'time': '2018年6月5日',
              'title': 'Python3 * 和 ** 运算符_极客点儿-CSDN博客',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=Wo6dq8qZ24BrXjb6ZO5Ft20HEUmtEvGn7zTArPFe6IGnYYID3jjhQK_iwtP2G_rawgQLa52_68YRCVWzYjfPyptYEJmoGu-kDlTsmNoJ26S'},
             {'des': '首先上一首 Python 之禅:我从 2015 年 3 月第一次接触 Python 这门语言(之前一直写 '
                     'PHP),就对其简洁…',
              'origin': '知乎',
              'time': '2019年3月28日',
              'title': '你都用 Python 来做什么? - 知乎',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=9Yve5ybsv1wP2WlxkOqO0z7wa_DaY__D1bTMLOaxT_UAqayv9RVWNHOjo68Hj1GycG5KSNutW6ofYdO4pYsjrTBz3Pe4hl-yQRxMtOfiWES'},
             {'des': 'Python是由创始人贵铎·范·罗萨姆(Guido van '
                     'Rossum)在阿姆斯特丹于1989年圣诞节期间,为了打发圣诞节的无趣,开发的一个新的解释型脚本语言。',
              'origin': 'www.yunweipai.com/python',
              'time': '2019年4月25日',
              'title': 'Python教程 - 运维派',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=px_zi74_EXc23TEOILqPGQfW49CRQv448R7MXLXGQiV-HQNiuxW8sYGRhasJSOVp'},
             {'des': '这套Python基础教程通俗易懂,深入浅出,旨在帮助大家快速入门。这套Python教程虽然学习门槛低,但是知识体系很丰富,并且包含了大量实例,让大家学以致用。',
              'origin': 'c.biancheng.net/python',
              'time': None,
              'title': 'Python基础教程,Python入门教程(非常详细)_C语言中文网',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=etpIrqd8bVpZzDq54FotETIfGChVtHeVAjLjdVHgdFSyN-jvo421D01Tdjt7FsJ9'},
             {'des': 'Python 100例 以下实例在Python2.7下测试通过: Python 练习实例1 Python '
                     '练习实例2 Python 练习实例3 Python 练习实例4 Python 练习实例5 Python '
                     '练习实例6 Python...',
              'origin': 'www.runoob.com/python/python-1...',
              'time': None,
              'title': 'Python 100例 | 菜鸟教程',
              'type': 'result',
              'url': 'http://www.baidu.com/link?url=pMlhzHAsK3rai-RLPA0nY_s1nahEjH5nrkPw23lbXbCUWeV0moA3vvMfa0wTSSpJ0FUjizbPCEq0d_lIFiGiHK'}],
 'total': 10}

更详细的新手教程可在文档中找到。


维护BaiduSpider


如果你想要参与BaiduSpider的维护工作,我将十分感激!维护的方式多种多样,可以通过提交新的issue,可以为新手解答issue,甚至提交一个PR


特别致谢


  • 感谢requests提供爬虫的HTTP获取网页的支持

  • 感谢MkDocsMaterial for MkDocs提供的精致的文档框架

  • 感谢FastAPI提供的小巧但强大的Web API框架,为BaiduSpider即将发布的API提供了支持

  • 感谢Vue这个强大的前端框架,为BaiduSpider的前端提供了强有力的支持

  • 感谢所有对BaiduSpider提交错误报告,解答issue,和提交PR的你们!

baiduspider's People

Contributors

dependabot[bot] avatar samzhangjy 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.