美文网首页
爬虫入门之抓取糗事百科热门

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

作者: NoValue | 来源:发表于2017-05-06 23:39 被阅读53次

效果图

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)

相关文章

网友评论

      本文标题:爬虫入门之抓取糗事百科热门

      本文链接:https://www.haomeiwen.com/subject/qegytxtx.html