我用Python爬取美食网站3032个菜谱并分析,真香!

数据分析实例-餐饮行业分析 本次数据分析案例共有8道题开发工具:jupyter bootbook话不多说,首先导入本次案例需要用到的包 1. 读取“餐饮订单”表格数据命名为order,并查看第5行到第10行数据。 巧妙的利用head()和tail()来实现读取任意区间的数据2. 读取”就餐人数”表格数据命名为customer,并按就餐人数进行升序排序,并查看第5行到第10行数据。 3.为order表增加一列“时间段”,将16点及之前的订单标记为午餐,16点后的订单标记为晚餐。并根据数量和单价计算出销售额。并查看前5行数据。 阅读详情

在这里插入图片描述
这是巨变的中国,人和食物,比任何时候走的更快。近日,J哥为了寻味中国,奔走于某五线城市的大街小巷,结果除了累,啥也没寻到。

于是,J哥默默打开了各大美食网站,如豆果美食、下厨房、美食天下等。经过甄选,最终爬取了豆果网最新发布的中国菜系共3032个菜谱,然后清洗数据并做可视化分析,试图走上美食博主的康庄大道。

数据获取

豆果美食网的数据爬取比较简单,如果您对爬虫感兴趣,可查看J哥往期原创文章「实战|手把手教你用Python爬虫(附详细源码)」,思路一致。
在这里插入图片描述

本文爬取的数据范围为川菜、粤菜、湘菜等八个中国菜系,包含菜谱名、链接、用料、评分、图片等字段。限于篇幅,仅给出核心代码。

 # 主函数
def main(x):
    url = 'https://www.douguo.com/caipu/{}/0/{}'.format(caipu,x*20)
    print(url)
    html = get_page(url)
    parse_page(html,caipu)


if __name__ == '__main__':
    caipu_list = ['川菜', '湘菜','粤菜','东北菜','鲁菜','浙菜','湖北菜','清真菜'] #中国菜系
    start = time.time()  # 计时
    for caipu in caipu_list:
        for i in range(22):
            # 爬取多页
            main(x=i)
            time.sleep(random.uniform(1, 2))
            print(caipu,"第" + str(i+1) + "页提取完成")
    end = time.time()
    print('共用时',round((end - start) / 60, 2), '分钟')

数据清洗

短短几分钟就爬下了3032个菜谱信息,为了方便可视化分析,还需要对爬取的数据进行简单清洗。

本文数据清洗主要用到Python的Pandas库,如果您对Pandas感兴趣,可查看J哥往期原创专辑「Pandas基础系列」,共五篇。

导入数据

用pd.read方法导入爬取到的菜谱数据,并添加列名。

import pandas as pd
import numpy as np
df = pd.read_csv('/Users/spider_cook/cai.csv'
                 ,names = ['菜谱','菜谱链接', '用料', '评分', '用户','图片','菜系'])
df.head()

删除重复项

爬虫过程中少量菜谱数据被重复抓取,需要用drop_duplicates方法删除。

df = df.drop_duplicates() 

缺失值处理

通过info方法发现少量记录含有缺失值,用dropna方法删除。

df.info()
df = df.dropna(axis
python爬虫项目(十九):爬取各大美食网站食谱数据,建立美食推荐系统 随着互联网的发展,美食网站如雨后春笋般涌现,成为了用户获取食谱和烹饪技巧的重要平台。本项目旨在爬取各大美食网站的食谱数据,构建一个美食推荐系统,帮助用户更轻松地找到他们感兴趣的食谱。通过爬取各大美食网站的食谱数据并构建美食推荐系统,我们能够为用户提供个性化的食谱推荐。这种推荐系统不仅能提高用户的体验,还能为美食网站带来更高的用户黏性。未来可以考虑加入更多的用户行为数据和食谱特征,以提升推荐的准确性。可以使用用户的评分数据构建用户-食谱矩阵,使用ALS(交替最小二乘法)或SVD(奇异值分解)进行推荐。 阅读详情

相关推荐

python爬取美食数据根据人气可视化基于XPath的HTML解析器以及数据保存到csv

python数据爬取美食网站xpath解析并将美食数据存入csv文件按照人气数据分析可视化

qq_22593423的博客 439

Python实战:3步搞定视频去重,告别重复文件烦恼(附完整代码)

本文提供了一套基于Python的视频去重实战方案,通过三步流程(抽帧、生成内容指纹、相似度比对)高效识别重复视频文件。文章详细介绍了使用dHash算法生成视频指纹的核心原理,并提供了完整的代码实现,帮助用户快速构建自己的视频去重工具,告别重复文件管理烦恼。

weixin_29054245的博客 373

⭐️白嫖的阿里云认证⭐️ 【真题&参考答案】:大模型Clouder认证:利用大模型提升内容生产能力

【摘要】真题「大模型Clouder认证:利用大模型提升内容生产能力」

davidkorhenn的博客 1905

《最游记》游戏开发全栈指南:从源码解析到实战部署

本文提供了一份详尽的《最游记》游戏源码全栈开发指南。文章深入解析了这款3D玄幻网游的完整源码结构,涵盖客户端、服务端、引擎和工具链,并提供了从环境搭建、核心模块解析到实战修改与部署的完整流程。对于希望深入理解MMORPG架构的开发者而言,这份指南是宝贵的实战资源。

weixin_28363123的博客 71

TDSQL-单机安装

根据腾讯云官方要求,TDSQL安装至少需要三台机器。本人想要学习TDSQL但是没有足够的机器资源,经过仔细分析研究TDSQL安装过程,尝试发现单台机器也可以成功安装TDSQL,现将本人单台机器安装TDSQL的过程以及安装过程中遇到的问题在此分享。具体安装过程可参考腾讯官方文档,本文仅分享与官方文档不一致的步骤。

u012607648的博客 6780

python 爬取携程全国旅游景点信息-2024.4.13

携程网是中国领先的在线旅行服务公司,提供酒店预订、机票预订、旅游度假、商旅管理等服务。携程网上有大量的旅游景点和酒店信息,这些信息对于旅行者和旅游业者都有很大的价值。通过爬虫技术,我们可以从携程网上获取这些信息,并进行数据清洗、数据分析、数据可视化等操作,从而得到有用的洞察和建议。

britlee的博客 1万+

虚拟机VMware Horizon Client与主机之间建立共享文件夹

因经常需要在虚拟机和主机之间传递一些日常文件,所以建立共享文件夹。 虚拟机中安装的系统为win10,主机中的系统为win10。 步骤: 第一步:先在虚拟机win10中新建文件夹(我重命名为“共享文件夹”),然后右键属性->共享->共享 进去之后点击自己的账户名 然后点共享。操作完成后,再返回属性界面就能看到该文件夹已经共享而且出现了共享链接,记下此链接。 第二步:回到主机桌面->此电脑->最上面计算机->添加一个网络位置- 点击下一步 然后自定义网络位置,下一步,如下图

AnChenliang_1002的博客 1万+

Moviepy自动化剪辑视频中的广告

本教程展示了如何使用 Python 中的 MoviePy 库,通过检测和剪辑广告段落来实现视频内容的清洁播放。通过广告检测算法和 MoviePy 剪辑功能的结合,可以自动化处理视频,极大提升编辑效率。在学习和应用中,理解广告检测的原理及其实现方法尤为重要,以便针对不同类型的视频进行调整。此外,MoviePy 的灵活性使其适用于多种视频编辑场景,适合自动化内容制作与优化。

Mr数据杨 3392

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ssm框架搭建

这个是一个在idea上成功跑起来的ssm框架项目,保存在这里方便以后使用直接下载

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

上一篇: Python爬取链家网24685个租房信息并进行数据分析
下一篇: Pandas爬虫,竟能如此简单!
菜J学Python
博客等级 码龄7年 130粉丝 21原创
评论 3
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值