When setting up sources in Telematic.pro, correctly configuring CSS selectors plays a crucial role. They allow you to:
For effective parsing, you need to find the correct selectors using DevTools in your browser. In this article, we'll go over how to do this.
In Google Chrome or Firefox, press F12 or Ctrl + Shift + I (on Mac: Cmd + Option + I) to open the Developer Tools (DevTools).
Suppose we want to extract links to articles from the main page of the blog "https://example.com/news".
<a>
tag that contains the article link.Example HTML code:
<article class="news-item">
<a href="/news/article-123" class="news-link">Article Title</a>
</article>
This means the CSS selector for links will be:
.news-item .news-link
In Telematic.pro, enter this selector in the Link CSS Selector field.
After obtaining the list of links, the system navigates to each article and extracts the content. We need to specify where it is located.
<div>
, <article>
, or <section>
).Example HTML code:
<article class="article-content">
<h1>Article Title</h1>
<p>Article text...</p>
</article>
CSS selector for content:
.article-content
Enter this in Telematic.pro under Content CSS Selector.
Sometimes, articles contain unwanted elements such as ads, social media buttons, or links to other materials.
document.querySelectorAll('selector')
If multiple elements are found, you may need to refine the selector.Example HTML code with unwanted elements:
<article class="article-content">
<h1>Article Title</h1>
<p>Article text...</p>
<div class="related-posts">Other articles</div>
<div class="ad-banner">Advertisement</div>
</article>
Excluding CSS selectors:
.related-posts, .ad-banner
Add these to the Excluding CSS Selectors field in Telematic.pro.
Let's say we are configuring a source for a blog with the URL https://example.com/news
. The settings in Telematic.pro would be:
.news-item .news-link
.article-content
.related-posts, .ad-banner
Configuring CSS selectors allows you to precisely extract the necessary data while excluding unwanted elements. Use DevTools to find the correct selectors, copy them via the context menu, and test them in the console before adding them to Telematic.pro.