# Can't get href from HTML selector node

**URL:** <https://discourse.nodered.org/t/cant-get-href-from-html-selector-node/77441>\
**Category:** General\
**Tags:** http-request\
**Created:** [10 April 2023 23:34 UTC](https://discourse.nodered.org/t/cant-get-href-from-html-selector-node/77441 "2023-04-10T23:34:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![arduino](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@arduino](https://discourse.nodered.org/u/arduino)\
**Post date:** [10 April 2023 23:34 UTC](https://discourse.nodered.org/t/cant-get-href-from-html-selector-node/77441/1 "2023-04-10T23:34:28Z")

</div>

Hello ,  
I need to scrap a website data ( productName, productCategory, productPrice ) .  
I have done all those items , still just to get the href from a tag .

- The website contain multiple links to be scrapped .  
Im using injectNode --\>HTTP Get --\>HTML Selector --\>debug .  
Can you please support how can I get **href** using HTML selector node .  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/b/fb216fa575a938bf6f9ad88018f65305d7829bc6.png)

Thank you.

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [10 April 2023 23:59 UTC](https://discourse.nodered.org/t/cant-get-href-from-html-selector-node/77441/2 "2023-04-10T23:59:06Z")

</div>

Welcome to the forum @arduino

You can export your Node-red flow (from the hamburger menu) and post it here using the `</>` button.  
You can tell us the URL of the website you are seeking to scrape data from.  
You can show us the output you are currently getting.

WIthout any of those things it's not easy to help.

---

<div class="post-metadata">

**Author:** ![arduino](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@arduino](https://discourse.nodered.org/u/arduino)\
**Post date:** [11 April 2023 00:55 UTC](https://discourse.nodered.org/t/cant-get-href-from-html-selector-node/77441/3 "2023-04-11T00:55:05Z")

</div>

Thank **jbudd** for your reply .

```auto
[{"id":"c151e39cb3680769","type":"tab","label":"Web Scarpping","disabled":false,"info":"","env":[]},{"id":"b3e1e48f764ee301","type":"inject","z":"c151e39cb3680769","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":110,"y":180,"wires":[["aeb75201ebb12ab8"]]},{"id":"aeb75201ebb12ab8","type":"http request","z":"c151e39cb3680769","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://shop4makers.com/produit/capteur-tof-de-distance-vl6180x/","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":270,"y":300,"wires":[["3569b6490a7f33ec","94813323991c69f9","fdf44f74be292a5d","c2374ee4dd10df39","7a31b877a7f84d8b","ebef5a76010e6912"]]},{"id":"647ace372ae75ec7","type":"debug","z":"c151e39cb3680769","name":"debug 27","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":220,"wires":[]},{"id":"3569b6490a7f33ec","type":"html","z":"c151e39cb3680769","name":"availibility","property":"payload","outproperty":"payload","tag":"span.electro-stock-availability p","ret":"text","as":"single","x":500,"y":220,"wires":[["647ace372ae75ec7"]]},{"id":"9c9b936c8ec1ee20","type":"debug","z":"c151e39cb3680769","name":"debug 28","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":260,"wires":[]},{"id":"94813323991c69f9","type":"html","z":"c151e39cb3680769","name":"productName","property":"payload","outproperty":"payload","tag":"div.summary.entry-summary h1","ret":"text","as":"single","x":520,"y":260,"wires":[["9c9b936c8ec1ee20"]]},{"id":"5e32f9da1d68dfe3","type":"debug","z":"c151e39cb3680769","name":"debug 29","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":300,"wires":[]},{"id":"fdf44f74be292a5d","type":"html","z":"c151e39cb3680769","name":"currentPrice","property":"payload","outproperty":"payload","tag":"p.price>span>ins","ret":"text","as":"single","x":510,"y":300,"wires":[["5e32f9da1d68dfe3"]]},{"id":"e54aea7a7074b59c","type":"debug","z":"c151e39cb3680769","name":"debug 30","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":340,"wires":[]},{"id":"c2374ee4dd10df39","type":"html","z":"c151e39cb3680769","name":"categories","property":"payload","outproperty":"payload","tag":"div.summary.entry-summary>span","ret":"text","as":"single","x":510,"y":340,"wires":[["e54aea7a7074b59c"]]},{"id":"7a31b877a7f84d8b","type":"html","z":"c151e39cb3680769","name":"oldPrice","property":"payload","outproperty":"payload","tag":"p.price del","ret":"text","as":"single","x":500,"y":380,"wires":[["e26a33a292356604"]]},{"id":"e26a33a292356604","type":"debug","z":"c151e39cb3680769","name":"debug 31","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":380,"wires":[]},{"id":"ebef5a76010e6912","type":"html","z":"c151e39cb3680769","name":"productDescription","property":"payload","outproperty":"payload","tag":"div.woocommerce-product-details__short-description","ret":"text","as":"single","x":530,"y":420,"wires":[["5d6ab7a1674c8581"]]},{"id":"5d6ab7a1674c8581","type":"debug","z":"c151e39cb3680769","name":"debug 32","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":760,"y":420,"wires":[]},{"id":"aa458c47c5b6ca5a","type":"inject","z":"c151e39cb3680769","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":540,"wires":[["12448c9f0cc9fcb5"]]},{"id":"12448c9f0cc9fcb5","type":"http request","z":"c151e39cb3680769","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://shop4makers.com/categorie-produit/capteurs/","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":250,"y":540,"wires":[["f52fb90282407e72"]]},{"id":"5d5ccbe86cb246b6","type":"debug","z":"c151e39cb3680769","name":"debug 33","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":800,"y":540,"wires":[]},{"id":"f52fb90282407e72","type":"html","z":"c151e39cb3680769","name":"productLinks","property":"payload","outproperty":"payload","tag":"nav.woocommerce-pagination li","ret":"text","as":"single","x":430,"y":540,"wires":[["1ed16c98242f5377"]]},{"id":"1ed16c98242f5377","type":"function","z":"c151e39cb3680769","name":"convertToNumber","func":"var pages = msg.payload;\nvar lastPage = pages[pages.length -2];\n\n\nmsg.payload = Number(lastPage);\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":630,"y":540,"wires":[["5d5ccbe86cb246b6"]]},{"id":"0e9b22f08160df1d","type":"comment","z":"c151e39cb3680769","name":"get last page","info":"Get last page","x":110,"y":480,"wires":[]},{"id":"f004f34fec70473b","type":"comment","z":"c151e39cb3680769","name":"get data from 1 single product","info":"Get the data from 1 single product","x":380,"y":160,"wires":[]},{"id":"eb218565d5cb5836","type":"inject","z":"c151e39cb3680769","name":"","props":[],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":90,"y":720,"wires":[["8941fbed1e8ccd96"]]},{"id":"8941fbed1e8ccd96","type":"http request","z":"c151e39cb3680769","name":"","method":"GET","ret":"txt","paytoqs":"ignore","url":"https://shop4makers.com/categorie-produit/capteurs/","tls":"","persist":false,"proxy":"","insecureHTTPParser":false,"authType":"","senderr":false,"headers":[],"x":250,"y":720,"wires":[["cc098ff19ddfeede"]]},{"id":"3a0555d9d6fa336c","type":"debug","z":"c151e39cb3680769","name":"debug 34","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":640,"y":720,"wires":[]},{"id":"cc098ff19ddfeede","type":"html","z":"c151e39cb3680769","name":"productLinks","property":"payload","outproperty":"payload","tag":"div.product-loop-body.product-item__body","ret":"html","as":"single","x":470,"y":720,"wires":[["3a0555d9d6fa336c"]]},{"id":"1066fb87ca373d75","type":"comment","z":"c151e39cb3680769","name":"get Links of all products","info":"get links of products","x":140,"y":660,"wires":[]}]

```

- Here is the URL that I need to scrap data from : [Capteurs Archives | Shop4Makers-Vente Arduino au Maroc](https://shop4makers.com/categorie-produit/capteurs/)
- Here is a screenshot of href that I need to get for each product.  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/1/516ce2665049410a133341a978b5b94b0515f662.jpeg)

Thank you .

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [11 April 2023 06:27 UTC](https://discourse.nodered.org/t/cant-get-href-from-html-selector-node/77441/4 "2023-04-11T06:27:54Z")

</div>

Try `div.product-loop-body.product-item__body > a`  
and set the output to `an object of any attributes of the elements`

---

<div class="post-metadata">

**Author:** ![arduino](https://avatars.discourse-cdn.com/v4/letter/a/c89c15/32.png) [@arduino](https://discourse.nodered.org/u/arduino)\
**Post date:** [11 April 2023 08:02 UTC](https://discourse.nodered.org/t/cant-get-href-from-html-selector-node/77441/5 "2023-04-11T08:02:56Z")

</div>

Thank you , works exactly as expected .

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/6/c680ed59acce4471b04bde707cdafbbd57d9318c.png)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [25 April 2023 08:03 UTC](https://discourse.nodered.org/t/cant-get-href-from-html-selector-node/77441/6 "2023-04-25T08:03:14Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
