J
J
just_obs2021-09-28 20:44:29
JavaScript
just_obs, 2021-09-28 20:44:29

How can I find the line I need in the text?

There is such a response from the server in the form of text (it is actually 40 times more):

</div><div class="card-buttons"><!--noindex--><div class="item-button sale_button hide"><a class="btn btn-fire btn-product button-buy giftcard" href="?in_id=317400" rel="nofollow"><span itemprop="availability" href="http://schema.org/OutOfStock">Оформить заказ</span></a><!--noindex--><a class="btn btn-default btn-product button-in_cart hide" href="/basket/orders/" rel="nofollow">В корзине</a><!--/noindex--><a class="btn btn-border btn


There is this line here:
<span itemprop="availability" href="http://schema.org/OutOfStock">


The question is simple: How can I parse/get the content from the href tag? Given that fetch returns text to me, and not just markup?
I apologize in advance to the professionals, I'm just starting to understand here!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
Chipekwe, 2021-09-28
@just_obs

/(?<="availability" href=").+?(?=">)/
Or you can parse the received response into the DOM and search through querySelector and attributes:
https://developer.mozilla.org/en/docs/Web/API/DOMParser

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question