我从请求中获得的html内容如下,
<meta id="state" content="{"config": {"application_string_templates": {"cta.button": "Book Appointment", "facet.insurance_plans.typeahead.placeholder": "Choose Insurance Accepted", "facet.languages.language.typeahead.placeholder": "Choose Language", "facet.location.placeholder": "City, State (e.g. Atlanta, GA) or Zip", "facet.name.accepting_new_patients": "Accepting New Patients", "facet.name.age_groups_seen.name": "Age Groups Seen", "facet.name.direct_book_capable": "Book Online", "facet.name.gender": "Provider Gender", "facet.name.insurance_plans": "Insurance Accepted", "facet.name.is_primary_care": "Primary Care", "facet.name.is_specialty_care": "Specialty Care", "facet.name.languages.language": "Language"}">
在这里,我想获取属性内容的数据。 这是我的代码,
function parseData(html){
const {JSDOM} = jsdom;
const dom = new JSDOM(html);
const $ = (require('jquery'))(dom.window);
//let's start extracting the data
console.log($("#state"));
}
当我尝试通过id'state'获取它时,这是我得到的输出,
jQuery { '0': HTMLMetaElement {}, length: 1 }
任何人都可以请我帮忙。谢谢。