Giter Site home page Giter Site logo

house's Introduction

init - refer to jjs.py

#coding:utf-8

from bs4 import BeautifulSoup import urllib2

url = 'http://reeoo.com' request = urllib2.Request(url) response = urllib2.urlopen(request, timeout=20)

content = response.read() soup = BeautifulSoup(content, 'html.parser')

title

tag = soup.title print tag

<title>Reeoo - web design inspiration and website gallery</title> print tag.name # title

attribute

...

  • <script async type="text/javascript" src="//cdn.carbonads.com/carbon.js?zoneid=1696&serve=CVYD42T&placement=reeoocom" id="_carbonads_js"></script>
  • ...

    tag = soup.article c = tag['class']

    print c

    [u'box']

    find all, find

    通过 . 属性只能获取到第一个tag,若想获取到所有的 li 标签,可以通过 find_all() 方法 Find 只找第一个

    ls = soup.article.div.ul.find_all('li')

    find by atribute ID, class_

    soup.find_all(id='footer')

    [\n
    \n

    ...

    \n]

    #class should use class_

    class_="sister"

house's People

Contributors

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