简体   繁体   English

使用cheerio和javascript抓取内容

[英]Scrape content using cheerio and javascript

Given the following HTML content on a page:给定页面上的以下 HTML 内容:

       <div class="this-bold this-orange this-big">Latest Reading: 73&deg; <span class="this-smaller this-itlaic">(updated: July 21, 2021)</span></div><br />

I need to be able to scrape and return a string like:我需要能够刮取并返回一个字符串,如:

"73 degrees, updated: July, 21, 2021" “73 度,更新时间:2021 年 7 月 21 日”

How would I accomplish this in javascript using axios and cheerio?我将如何使用 axios 和cheerio 在javascript 中完成此操作?

The source URL for the HTML is: https://www.keukalakeassociation.org/charts/keuka_lake_temperature.php HTML 的源 URL 是: https : //www.keukalakeassociation.org/charts/keuka_lake_temperature.php

I appreciate your help!我感谢您的帮助!

You could use regex... something along the lines of this regex您可以使用正则表达式...与此正则表达式类似的东西

\<div class\=\"this-bold this-orange this-big\">([^\<]*)\<.*(updated: [^\)]*)

would help you extract something along the lines of this, using capture groups 1 and 2将帮助您使用捕获组 1 和 2 提取类似的内容

Latest Reading: 73&deg;  updated: July 22, 2021

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM