Web scraping, a technique for extracting data from websites. Widespread among companies and digital platforms, it can become a cybercrime if used unregulated.

Data is the gold of the 21st century. And like gold, there are those who mine it, collect it, and transform it. But what happens when it’s not a person doing the work, but a scraping software capable of automatically exploring and extracting information from thousands of web pages in just a few minutes?
What does "web scraping" mean?
The term web scraping refers to:
"An automated process of extracting data from websites, performed using software capable of reading and extracting structured information directly from HTML pages."
This technique is distinct from web crawling, which, instead, aims to explore and index web pages on behalf of search engines. While the former is aimed at collecting and processing data, the latter performs a mapping and archiving function for navigation and indexing purposes.
When we talk about scraping, we’re referring to an activity that involves querying a site’s servers via HTTP requests to extract information. In other words, it’s as if a program "reads" web pages as a user sees them, but does so in an automated and repetitive manner.
Not all forms of scraping are the same. There are two main categories: structured scraping, which operates on sites with an ordered and predictable data structure, and semantic scraping, which attempts to interpret the meaning of the analyzed content, often using artificial intelligence techniques to recognize relationships between words.
Purposes of Web Scraping: Who Uses It and What They Do With It
Web scraping is used by both public and private entities for purposes ranging from business to research, from marketing to data analysis.
"Its use spans different sectors, all of which share the need to access, analyze, and reprocess large volumes of data found online in a structured form."
One of the most common examples of web scraping being used by companies concerns the e-commerce sector.
"For example, price comparison websites rely on systematic scraping to detect the real-time costs of identical products offered by different sellers."
In the travel sector, scraping is used to collect and compare offers on flights, hotels, or vacation packages. Online travel agencies build their business model precisely on constant and automatic access to availability and price data published by airlines, hotels, and tour operators.
The journalism sector uses scraping to analyze public phenomena through content shared on social media, forums, or news sites. Data scraping allows journalists, political analysts, and scholars to access trends or events with a timeliness impossible to obtain with traditional methods.
Finally, it is not uncommon for scraping to be used in less legitimate fields. Some companies use it for lead generation purposes, that is, to collect email addresses or phone numbers published on websites, with the intent of building databases for unsolicited promotional campaigns.
How web scraping works, step by step
It all starts with sending an HTTP request. The software, often a bot, simulates the action of a browser and queries the server of the site from which it intends to collect information.
Once the HTML content of the page is received, DOM parsing comes into play. The Document Object Model (DOM) is the hierarchical structure of the web page: each element (text, image, link) is a node that can be navigated and analyzed.
A crucial aspect is session and cookie management.
"Some sites require an authenticated session to access certain content: this means the scraper must be able to manage credentials, keep the session active, and update cookies as a real user would."
Equally important is regulating the frequency of requests. Sending requests too frequently can generate security alerts and automatic blocks: this is why IP rotation, dynamic proxies, or services that offer anonymization networks are often used.
The most advanced scraping systems use headless browsers, such as Puppeteer or Selenium, capable of executing JavaScript code just as a visible browser would. To prevent the bot from being identified, anti-detect measures are used: techniques to mask the browser’s fingerprint, modify user agents, randomize behavior, and make each session unique.
One of the most common obstacles is anti-bot systems, such as CAPTCHA or challenge JavaScript. Here too, there are many solutions, from external automatic resolution services to the inclusion of waiting logic and artificial interaction to simulate human action.
The result is a system capable of acquiring and archiving data from heterogeneous sources.
How to Defend Yourself from Scraping
The first line of defense is technical. The robots.txt file indicates the areas of the site prohibited from automatic scanning. rate limits, which limit the number of requests allowed per IP address, help prevent mass access. Techniques such as fingerprint detection, on the other hand, allow us to distinguish human behavior from automated bots by analyzing browser characteristics, mouse movements, or the sequence of interactions.
In addition to technical defense, it is also necessary to implement legal tools to protect the site’s content and regulate access. The Terms of Service (ToS) clauses should specify the prohibition of scraping and the confidential or conditional nature of access to data. Such clauses may form the basis for civil liability actions or for sending legal notices, including through summary proceedings.
Furthermore, if the content is original, it is possible to invoke the copyright protection of the database, or the sui generis protection provided for by Directive 96/9/EC, and request the removal of the copied data.
Original article published on Money.it Italy. Original title: Cos’è il web scraping, come funziona e come difendersi