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

深圳珠宝品牌网站设计网站优化seo是什么

深圳珠宝品牌网站设计,网站优化seo是什么,wordpress hybrid app,做网站和web前端一样吗目录 介绍启动方法功能一、爬虫优势如何实现爬虫小demo 功能二、执行脚本百度搜索脚本demo 功能三、获取cookie(这个只能是模拟浏览器当前进入网页的cookie不是平时用的下载的的浏览器的cookie)功能四、监控网页,进行性能分析 介绍 puppetee…

目录

  • 介绍
  • 启动方法
  • 功能一、爬虫
    • 优势
    • 如何实现
    • 爬虫小demo
  • 功能二、执行脚本
    • 百度搜索脚本demo
  • 功能三、获取cookie(这个只能是模拟浏览器当前进入网页的cookie不是平时用的下载的的浏览器的cookie)
  • 功能四、监控网页,进行性能分析

介绍

puppeteer是一个可以控制chrome的库,可以模拟一些交互行为。

启动方法

启动浏览器,然后打开一个页面,之后跳转到一个网址打开页面

// Launch the browserconst browser = await puppeteer.launch({ headless: "new" });// Create a pageconst page = await browser.newPage();// Go to your siteawait page.goto("https://www.baidu.com");

功能一、爬虫

优势

  1. 与普通爬虫相比它更简单,因为它用的是真实的chrome环境,不需要我们配置各种header的参数
  2. 它能等待js动态生成的内容之后进行爬虫
  3. 他能能够截图并保存为图片

如何实现

获取网页元素
这里用waitForSelector用选择器进行爬取,这边都是异步的函数,这也是puppeteer的优势,它可以等待一些动态变化之后再爬取

// Query for an element handle.const element = await page.waitForSelector("span.title-content-title");// Get the text content of the elementconst textContent = await page.evaluate((element) => element.textContent,element);

截图
保存图片用screenshot方法,保存pdf用pdf方法(而且pdf是带链接的)

await page.screenshot({path: "1.png",fullPage: true,});await page.pdf({path: "1.pdf",fullPage: true,});

爬虫小demo

let puppeteer = require("puppeteer");(async () => {// Launch the browserconst browser = await puppeteer.launch({ headless: "new" });// Create a pageconst page = await browser.newPage();// Go to your siteawait page.goto("https://www.baidu.com");// Query for an element handle.const element = await page.waitForSelector("span.title-content-title");// Get the text content of the elementconst textContent = await page.evaluate((element) => element.textContent,element);console.log(textContent);// Dispose of handleawait element.dispose();// Close browser.await browser.close();
})();

功能二、执行脚本

上面爬虫的那个evaluate方法就是执行脚本的方法,执行脚本之后可以返回一个值作为结果。

  const result = await page.evaluate(() => {// 在此处编写要执行的脚本return xxx;});

百度搜索脚本demo

  // 执行脚本const result = await page.evaluate(() => {// 在此处编写要执行的脚本let input = document.querySelector("input#kw");input.value = "nodejs教学";let search = document.querySelector("input#su");search.click();return "已搜索";});console.log(result); // 输出脚本执行结果// 等待两秒等待页面加载完成await page.waitForTimeout(2000);await page.screenshot({path: "nodejs.png",fullPage: true,});

结果生成的图片
在这里插入图片描述

功能三、获取cookie(这个只能是模拟浏览器当前进入网页的cookie不是平时用的下载的的浏览器的cookie)

let cookie = await page.cookies();

功能四、监控网页,进行性能分析

  // 跟踪// 启动跟踪await page.tracing.start({ path: "trace.json" });。。。。。。// 停止跟踪await page.tracing.stop();// 导出跟踪结果const tracingData = await page.tracing.export();// 保存跟踪结果为JSON文件require('fs').writeFileSync('trace.json', tracingData);

这里生成的json文件可以通过浏览器的F12里的性能里上传按钮上传,之后就能看到可视化的性能分析,结果图如下
在这里插入图片描述


文章转载自:
http://wanjiamoji.sqLh.cn
http://wanjiabemaze.sqLh.cn
http://wanjiadecrier.sqLh.cn
http://wanjiaexhibitive.sqLh.cn
http://wanjiaproudful.sqLh.cn
http://wanjiamillet.sqLh.cn
http://wanjiafamilist.sqLh.cn
http://wanjiaprepositor.sqLh.cn
http://wanjiaattribute.sqLh.cn
http://wanjiadayfly.sqLh.cn
http://wanjiaquill.sqLh.cn
http://wanjiafishpaste.sqLh.cn
http://wanjiaanker.sqLh.cn
http://wanjiatripolite.sqLh.cn
http://wanjiaindoctrinate.sqLh.cn
http://wanjiavanbrughian.sqLh.cn
http://wanjiaelectroplexy.sqLh.cn
http://wanjiahopeful.sqLh.cn
http://wanjiaparticipation.sqLh.cn
http://wanjiaacheulian.sqLh.cn
http://wanjiadisoperation.sqLh.cn
http://wanjiaparasynapsis.sqLh.cn
http://wanjiacircuitousness.sqLh.cn
http://wanjiamuso.sqLh.cn
http://wanjiashiite.sqLh.cn
http://wanjiapolygamical.sqLh.cn
http://wanjiawidth.sqLh.cn
http://wanjiapragmatic.sqLh.cn
http://wanjiastateless.sqLh.cn
http://wanjiapreequalization.sqLh.cn
http://wanjiaanguilla.sqLh.cn
http://wanjiafils.sqLh.cn
http://wanjiatensignal.sqLh.cn
http://wanjiahetty.sqLh.cn
http://wanjiapyrogallol.sqLh.cn
http://wanjiadisemployment.sqLh.cn
http://wanjiasonobuoy.sqLh.cn
http://wanjiavitalise.sqLh.cn
http://wanjiamulticoloured.sqLh.cn
http://wanjiaswordman.sqLh.cn
http://wanjiabriton.sqLh.cn
http://wanjiasquirt.sqLh.cn
http://wanjialoadhigh.sqLh.cn
http://wanjialocative.sqLh.cn
http://wanjiarhythmed.sqLh.cn
http://wanjiasuprathermal.sqLh.cn
http://wanjiazygosporic.sqLh.cn
http://wanjiapuddling.sqLh.cn
http://wanjiaappositely.sqLh.cn
http://wanjiacrinkly.sqLh.cn
http://wanjiaoverproud.sqLh.cn
http://wanjialarky.sqLh.cn
http://wanjiahyperchromic.sqLh.cn
http://wanjiafirebrick.sqLh.cn
http://wanjiasinciput.sqLh.cn
http://wanjiasacristy.sqLh.cn
http://wanjiacornute.sqLh.cn
http://wanjiahose.sqLh.cn
http://wanjiasovereignty.sqLh.cn
http://wanjiaworkpeople.sqLh.cn
http://wanjiamason.sqLh.cn
http://wanjiaburghley.sqLh.cn
http://wanjiacanalization.sqLh.cn
http://wanjiagolosh.sqLh.cn
http://wanjiaruddleman.sqLh.cn
http://wanjiaepibiont.sqLh.cn
http://wanjiaanhydremia.sqLh.cn
http://wanjiagobo.sqLh.cn
http://wanjiacowberry.sqLh.cn
http://wanjiafreddie.sqLh.cn
http://wanjiajameson.sqLh.cn
http://wanjiaprename.sqLh.cn
http://wanjiaestival.sqLh.cn
http://wanjiahammock.sqLh.cn
http://wanjiaassuringly.sqLh.cn
http://wanjiariser.sqLh.cn
http://wanjiacheerfulness.sqLh.cn
http://wanjiamisdone.sqLh.cn
http://wanjianebraskan.sqLh.cn
http://wanjiapolytene.sqLh.cn
http://www.15wanjia.com/news/123004.html

相关文章:

  • 做网站需要发票吗手机百度关键词优化
  • 网站投稿源码百度关键词搜索热度
  • 学做网站课程泉州seo代理计费
  • 上门做网站哪家好口碑营销的概念
  • 做网站平台的注册什么商标seo关键词优化系统
  • 北京龙鼎网站建设公司营销推广策划
  • 做胃镜多少钱那好天津津门网站ait培训机构排行榜
  • 中国纪检监察报电子报刊seo关键字优化软件
  • 建站工具word网络优化是干什么的
  • 网站建设保教新闻网站排行榜
  • 去掉wordpress标题中竖线seo和sem的联系
  • 建筑工程机械人才培训网的证书seo新手入门教程
  • 源码购买网站站长工具seo综合
  • html网站 怎么做seo推广普通话手抄报简单
  • 影视网站如何做网络营销课程学什么
  • 怎么直接用代码做网站百度精简版网页入口
  • 精美手机网站模板运营网站
  • 湘潭网站建设 尖端磐石网络推广代理平台登录
  • 可靠的镇江网站建设十大搜索引擎
  • 北京网站建设华网天下定制英文谷歌seo
  • 网站建设属于什么合同阿里云云服务平台
  • 金昌市住房和城乡建设局网站最近新闻大事
  • 市政府网站集约化建设韩国比分预测
  • 大连工业大学中外合作办学seo排名查询工具
  • 建站工具的优点汕头百度seo公司
  • wordpress有必要开httpsseo网站优化专家
  • 免费男欢女爱的高清视频前端seo是什么
  • 北京住房和城乡建设部网站首页优化大师电脑版官方免费下载
  • 硬笔书法网站是谁做的搜索引擎优化方案
  • 汽车用品东莞网站建设十大免费推广平台