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

效果图

爬虫入门之抓取糗事百科热门_第1张图片
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)

你可能感兴趣的:(爬虫入门之抓取糗事百科热门)