爬虫入门之抓取糗事百科热门

2017-05-06  本文已影响53人  NoValue

效果图

choushi_baike.png
# -*- coding:utf-8 -*-
# **********************************
# ** http://weibo.com/lixiaodaoaaa #
# ****** by:lixiaodaoaaa ***********


import requests
import json
from bs4 import BeautifulSoup, Tag
from datetime import datetime


def convertUrlToBeautifulSoup(url):
    getStr = requests.get(url)
    getStr.encoding = "utf-8"
    return BeautifulSoup(getStr.text, "html.parser")


myCrapUlr = "http://www.qiushibaike.com/hot/"
mySoup = convertUrlToBeautifulSoup(myCrapUlr)
for content in mySoup.select(".content"):
    print(content.text)
上一篇 下一篇

猜你喜欢

热点阅读