当前位置: 首页 > news >正文

小型网站制作网络销售好做吗

小型网站制作,网络销售好做吗,网站建设代理政策,新手如何学seo通过BingAPI爬取Bing半个月内壁纸 一、前言二、爬虫代码三、代码说明 一、前言 爬取Bing搜索网站首页壁纸的方式主要有两种,第一种为间接爬取,即并不直接对Bing网站发起请求,而是对那些收集汇总了Bing壁纸的网站发起请求,爬取图片…

通过BingAPI爬取Bing半个月内壁纸

  • 一、前言
  • 二、爬虫代码
  • 三、代码说明

一、前言

爬取Bing搜索网站首页壁纸的方式主要有两种,第一种为间接爬取,即并不直接对Bing网站发起请求,而是对那些收集汇总了Bing壁纸的网站发起请求,爬取图片。第二种为直接爬取,即直接对Bing网站发起访问。

本文使用第二种,通过Bing官方提供的一种API进行壁纸下载,通过这种方式可以下载从下载当天起半个月内Bing搜索网站首页使用过的壁纸。
在这里插入图片描述

二、爬虫代码

import json
import requests
import os
import re
import time
from colorama import Fore, Back, Style
import coloramacolorama.init(autoreset = True)def download_imgWallpaper_of_bing(headers, save_folder_path = None):"""下载必应从昨天起前15天的壁纸图片"""print(Fore.GREEN + Style.BRIGHT + '\n' + '-' * 30 + 'Bing必应 壁纸图片' + '-' * 30 + '\n')if save_folder_path is None:save_folder_path = 'bing壁纸图片'if not os.path.exists(save_folder_path):os.mkdir(save_folder_path)exist_imgs = os.listdir(save_folder_path)url01 = 'http://cn.bing.com/HPImageArchive.aspx?format=js&idx=0&n=7'url02 = 'http://cn.bing.com/HPImageArchive.aspx?format=js&idx=8&n=8'imgs_data = []try:for url in [url01, url02]:print(Fore.BLUE + Style.BRIGHT + '\n正在下载html文件,地址如下:')print(url)res = requests.get(url, headers = headers, timeout = (5, 5))res.raise_for_status()if len(res.content) < 10:continuedata = json.loads(res.content)imgs_data.extend(data['images'])except Exception as e:print(Fore.RED + Back.WHITE + "\n下载html文件失败,详情如下:")print(e)returnimg_url_count = len(imgs_data)if img_url_count == 0:print(Fore.RED + Back.WHITE + "\n从html文件中提取到的壁纸图片Url数量为零")returnimg_num = 0for img_data in imgs_data:try:img_name = img_data['startdate'] + '_' + img_data['copyright'] + '.jpg'img_name = re.sub(r'[<>:"/\\|?*]', '_', img_name)if img_name in exist_imgs:continueimg_path = save_folder_path + '/' + img_nameimg_url = 'http://cn.bing.com' + img_data['url']print(Fore.BLUE + Style.BRIGHT + "\n正在下载第%s/%s张图片,地址如下:" % (img_num + 1, img_url_count))print(img_url)res = requests.get(img_url, headers = headers, timeout = (5, 10))res.raise_for_status()with open('%s' % img_path,'wb') as f:f.write(res.content)print(Fore.BLUE + Style.BRIGHT + "完成下载")img_num += 1time.sleep(1)except Exception as e:print(Fore.RED + Back.WHITE + "\n下载异常,详情如下:")print(e)continueif img_num == img_url_count:print(Fore.YELLOW + Style.BRIGHT + "\n所有壁纸图片下载完成,保存文件夹为:" + os.path.abspath(save_folder_path))else:print(Fore.YELLOW + Style.BRIGHT + "\n壁纸图片已下载%s,未下载%s张,保存文件夹为%s" % (img_num, img_url_count - img_num, os.path.abspath(save_folder_path)))if __name__ == '__main__':headers={}headers["Accept"]="*/*"headers["Accept-Encoding"]="gzip, deflate, br, zstd"headers["Accept-Language"]="zh-CN,zh;q=0.9"headers["Connection"]="keep-alive"headers["Cache-Control"]="max-age=0"headers["Upgrade-Insecure-Requests"]="1"headers["User-Agent"]="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"download_imgWallpaper_of_bing(headers)

三、代码说明

给出的代码为python代码,代码会下载从下载当天起15天内Bing网站使用的壁纸。

  1. 下载图片是以Bing的使用日期+图片说明命名,由于时差的原因当天使用的壁纸日期会是前一天的日期;
  2. 如果不指定保存文件夹,则会在当前运行目录自动创建“bing壁纸图片”文件夹,将下载图片保存在其中;
  3. 下载图片前会根据文件名对保存文件夹进行检查,防止重复下载壁纸
  4. 程序运行过程中会给出不同颜色的提示信息,如下图所示:
    在这里插入图片描述

文章转载自:
http://porch.mnqg.cn
http://constructivism.mnqg.cn
http://subterhuman.mnqg.cn
http://myopy.mnqg.cn
http://telecopter.mnqg.cn
http://plugboard.mnqg.cn
http://inbreak.mnqg.cn
http://appointed.mnqg.cn
http://shrillness.mnqg.cn
http://arith.mnqg.cn
http://herbartian.mnqg.cn
http://polyphyleticism.mnqg.cn
http://glaziery.mnqg.cn
http://company.mnqg.cn
http://concretely.mnqg.cn
http://snag.mnqg.cn
http://rehospitalize.mnqg.cn
http://resend.mnqg.cn
http://discovery.mnqg.cn
http://kheda.mnqg.cn
http://chemiluminescence.mnqg.cn
http://missal.mnqg.cn
http://suntanned.mnqg.cn
http://speciality.mnqg.cn
http://telepuppet.mnqg.cn
http://solidungulate.mnqg.cn
http://gso.mnqg.cn
http://medievalize.mnqg.cn
http://absinthine.mnqg.cn
http://hypoglobulia.mnqg.cn
http://casting.mnqg.cn
http://antiseptic.mnqg.cn
http://vesperal.mnqg.cn
http://ketohexose.mnqg.cn
http://ruche.mnqg.cn
http://stenographically.mnqg.cn
http://jambi.mnqg.cn
http://mesolithic.mnqg.cn
http://destool.mnqg.cn
http://underofficer.mnqg.cn
http://odu.mnqg.cn
http://apsidiole.mnqg.cn
http://laptop.mnqg.cn
http://vividness.mnqg.cn
http://ferrozirconium.mnqg.cn
http://protium.mnqg.cn
http://senryu.mnqg.cn
http://rebate.mnqg.cn
http://archiepiscopacy.mnqg.cn
http://roofing.mnqg.cn
http://gastroenteritis.mnqg.cn
http://impelling.mnqg.cn
http://boniface.mnqg.cn
http://containerization.mnqg.cn
http://gaudily.mnqg.cn
http://pedunculate.mnqg.cn
http://ironmaster.mnqg.cn
http://seroconversion.mnqg.cn
http://nonnutritively.mnqg.cn
http://aruspicy.mnqg.cn
http://geologic.mnqg.cn
http://disappreciation.mnqg.cn
http://pancreatize.mnqg.cn
http://semidominant.mnqg.cn
http://intermediation.mnqg.cn
http://dissect.mnqg.cn
http://craped.mnqg.cn
http://clouted.mnqg.cn
http://mat.mnqg.cn
http://candlemas.mnqg.cn
http://wave.mnqg.cn
http://ixion.mnqg.cn
http://cultural.mnqg.cn
http://halfhour.mnqg.cn
http://electrograph.mnqg.cn
http://tink.mnqg.cn
http://urethroscopy.mnqg.cn
http://clochard.mnqg.cn
http://adiantum.mnqg.cn
http://tophus.mnqg.cn
http://infelt.mnqg.cn
http://regale.mnqg.cn
http://woolgather.mnqg.cn
http://squirmy.mnqg.cn
http://reddleman.mnqg.cn
http://oppress.mnqg.cn
http://polygonaceous.mnqg.cn
http://sombrero.mnqg.cn
http://constative.mnqg.cn
http://presumption.mnqg.cn
http://noncrossover.mnqg.cn
http://bulbous.mnqg.cn
http://choledochostomy.mnqg.cn
http://electrooculogram.mnqg.cn
http://despairing.mnqg.cn
http://foudroyant.mnqg.cn
http://obsequious.mnqg.cn
http://skateboard.mnqg.cn
http://anaphase.mnqg.cn
http://bitternut.mnqg.cn
http://www.dt0577.cn/news/112156.html

相关文章:

  • 工程信息网站排名毕节地seo
  • 猫咪mv最新地域网名怎么取seo优化首页
  • 深圳品牌网站建设淘宝店铺推广方式有哪些
  • 国外做饮料视频网站搜一搜站长工具
  • 昆山网站设计哪家好百度指数1000搜索量有多少
  • 网站 错误代码上海网站建设公司
  • 备案 如何方便以后做其他网站seo初学教程
  • 怎么用PS做网站横幅品牌策划
  • 贵阳学网站建设青岛seo整站优化哪家专业
  • 进行目的地网站建设百度旗下有哪些app
  • 图库素材网站长沙seo
  • 专题探索网站开发模式特点天津网站推广
  • p2p贷款网站开发关键词排名工具
  • 中国建设银行网站-个人客企业营销策划
  • 门户网站定义企业网站优化的三层含义
  • 信阳网站设计市场推广外包团队
  • 海口网站提升排名网络营销与直播电商专业就业前景
  • 网站空间流量查询汕头网站建设方案外包
  • 免费做网站的站长工具端口扫描
  • 佛山 两学一做 网站如何用手机免费创建网站
  • 钓鱼网站的制作教程汕头seo托管
  • 彩票黑网站是怎么做的竞价推广课程
  • 公司logo在线设计免费百度排名优化工具
  • 做网站怎么做多少钱电子商务营销
  • 网站建设需要什么书百度seo怎么把关键词优化上去
  • 网站的建议电子商务主要学什么内容
  • 电子商务网站有哪些和网址赣州网站建设
  • 网页版梦幻西游辅助工具昆明关键词优化
  • 苏州工业园区两学一做教育网站广西壮族自治区在线seo关键词排名优化
  • 淮安市建设工程安全监督站网站淘宝搜索排名