Simple scrapping question

Issue/error/question

Hello, I’m looking to scrape basic infos on an a page, after login. The connection seems to be ok, no error message but I can’t go further.

I spent an hour testing but I can’t find how to perform this simple operation.

On this first test, I try to retrieve my contact number on Active Campaign via the id "contacts_count”.

<camp-text id="contacts_count" size="fs1100" weight="fwRegular"

Test config screenshot
Html on page screenshot

Have you please, some idea ?

Tell me if you need more infos.

Cheers

Error message (if any)?

ERROR: Unmatched selector: =“contacts_count”

Workflow

Running n8n on desktop app (for the moment)

Hey @alternaz, welcome to the community :tada:

You can find a brief explanation of CSS selectors here on the MDN. To get an element with an ID of contacts_count, you’d use a selector of #contacts_count.

In most browser, you can also get a valid CSS selector by selector by right-clicking the respective element:

Lastly, in the HTML Extract node you can select HTML or Text rather than Value in order to get data outside of an input field as your screenshot would suggest:
image

Afterwards you should get the right data. Let me know if you run into any problems here (if so, it’d be great if you could share the HTML data returned by your HTTP Request node).

Hello MutedJam,

First, thanks for the reception, happy to be there with my low code level :stuck_out_tongue:

I found the right selector, it’s : #contacts_count, thanks for that.

I tried #contacts_count and contacts_count, (with html & text) and I receive no data.

Screenshot of data I get

I don’t know if this will be enough, don’t hesitate to tell me where I have to get the html data you wants if I ever missed something.

This is a loom with few tests : Loom | Free Screen & Video Recording Software

Hi @alternaz, this is most likely because the page you’re trying to scrape relies on browser functionality like JavaScript to render the number you want to extract dynamically. So you might want to take a look at the output of your HTTP Request node to see if the number is in there in the first place.

An alternative to getting a contact count from ActiveCampaign could be the use of the
ActiveCampaign node in n8n. Fetch all contacts you’re interested in through the node and then run a count, e.g. by using a Function node like this one:

Wow, really don’t know how can I implement that.

Question, can I have the result i’m lookin for (get the total number of contacts) with your API strategy ?

I don’t have an ActiveCampaign account myself, but I imagine it would be as simple as doing something as this in the ActiveCampaign node (obviously with valid credentials - the documentation describes how to set them up):

This would give you a list of all contacts (which you could also narrow down using the “Add Field” button at the bottom of my screenshot). Then connect the Function node from my last message to the ActiveCampaign node which should give you a count of all items. You can simply copy and paste the JSON code straight in your canvas.

Before even launching this topic, I had seen this documentation. AC does not allow, as part of its API, to achieve what I want to do. AC does not have a feature that allows you to have a total leads count, they are all separated, in separate lists.

Can you guide me regarding your first method? In addition I could reproduce it to extract other data on other sites!