Git Product home page Git Product logo

baiduspider's Introduction

mattzheng/BaiduSpider解析

fifths/python_baike_spider,对于新手来说不太友好... 但是功能强大,目前 该库可以实现:百度百科、百度词典的爬取。

必要的库:beautifulsoup4

pip install beautifulsoup4

1、baike_spider模块:百度百科

我这里对原作者的内容进行简单修改,可以指定路径保存 + 保存名称。

root_url = "http://baike.baidu.com/view/21087.htm"
save_path = './baike_spider/'
filename = 'output2.html'
obj_spider = SpiderMain()
obj_spider.craw(root_url,filename,save_path)

2、dict_spider模块:百度字典

主要用来解析百度词典: 这里写图片描述

word='人'
values = {
    'wd': word,
    'ptype': 'char'
}
data = urllib.parse.urlencode(values)
root_url = "http://dict.baidu.com/s?" + data + '#'
obj_spider = SpiderMain()
obj_spider.craw(root_url)

生成的链接为: 'http://dict.baidu.com/s?ptype=char&wd=%E4%BA%BA#'

baiduspider's People

Contributors

fifths avatar lee1031 avatar mattzheng avatar

Watchers

 avatar  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.