Web scraping, web harvesting, or web data extraction is
data scraping used for
extracting data from
website
A website (also written as a web site) is a collection of web pages and related content that is identified by a common domain name and published on at least one web server. Examples of notable websites are Google, Facebook, Amazon, and Wikip ...
s. Web scraping software may directly access the
World Wide Web
The World Wide Web (WWW), commonly known as the Web, is an information system enabling documents and other web resources to be accessed over the Internet.
Documents and downloadable media are made available to the network through web se ...
using the
Hypertext Transfer Protocol
The Hypertext Transfer Protocol (HTTP) is an application layer protocol in the Internet protocol suite model for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web, w ...
or a web browser. While web scraping can be done manually by a software user, the term typically refers to automated processes implemented using a
bot
Bot may refer to:
Sciences
Computing and technology
* Chatbot, a computer program that converses in natural language
* Internet bot, a software application that runs automated tasks (scripts) over the Internet
**a Spambot, an internet bot des ...
or
web crawler
A Web crawler, sometimes called a spider or spiderbot and often shortened to crawler, is an Internet bot that systematically browses the World Wide Web and that is typically operated by search engines for the purpose of Web indexing (''web spi ...
. It is a form of copying in which specific data is gathered and copied from the web, typically into a central local
database
In computing, a database is an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage. The design of databases spa ...
or spreadsheet, for later
retrieval
Retrieval could refer to:
Computer science
* RETRIEVE, Tymshare database that inspired dBASE and others
* Data retrieval
* Document retrieval
* Image retrieval
* Information retrieval
* Knowledge retrieval
* Medical retrieval
* Music informati ...
or
analysis
Analysis ( : analyses) is the process of breaking a complex topic or substance into smaller parts in order to gain a better understanding of it. The technique has been applied in the study of mathematics and logic since before Aristotle (3 ...
.
Scraping a web page involves fetching it and extracting from it. Fetching is the downloading of a page (which a browser does when a user views a page). Therefore, web crawling is a main component of web scraping, to fetch pages for later processing. Once fetched, extraction can take place. The content of a page may be
parsed, searched and reformatted, and its data copied into a spreadsheet or loaded into a database. Web scrapers typically take something out of a page, to make use of it for another purpose somewhere else. An example would be finding and copying names and telephone numbers, companies and their URLs, or e-mail addresses to a list (contact scraping).
As well as
contact scraping, web scraping is used as a component of applications used for
web indexing,
web mining and
data mining, online price change monitoring and
price comparison
Pricing is the process whereby a business sets the price at which it will sell its products and services, and may be part of the business's marketing plan. In setting prices, the business will take into account the price at which it could acq ...
, product review scraping (to watch the competition), gathering real estate listings, weather data monitoring,
website change detection, research, tracking online presence and reputation,
web mashup, and
web data integration.
Web pages are built using text-based mark-up languages (
HTML
The HyperText Markup Language or HTML is the standard markup language for documents designed to be displayed in a web browser. It can be assisted by technologies such as Cascading Style Sheets (CSS) and scripting languages such as JavaScri ...
and
XHTML
Extensible HyperText Markup Language (XHTML) is part of the family of XML markup languages. It mirrors or extends versions of the widely used HyperText Markup Language (HTML), the language in which Web pages are formulated.
While HTML, prior ...
), and frequently contain a wealth of useful data in text form. However, most web pages are designed for human
end-users
In product development, an end user (sometimes end-user) is a person who ultimately uses or is intended to ultimately use a product. The end user stands in contrast to users who support or maintain the product, such as sysops, system administrato ...
and not for ease of automated use. As a result, specialized tools and software have been developed to facilitate the scraping of web pages.
Newer forms of web scraping involve monitoring data feeds from web servers. For example,
JSON
JSON (JavaScript Object Notation, pronounced ; also ) is an open standard file format and data interchange format that uses human-readable text to store and transmit data objects consisting of attribute–value pairs and arrays (or other s ...
is commonly used as a transport storage mechanism between the client and the web server.
There are methods that some websites use to prevent web scraping, such as detecting and disallowing bots from crawling (viewing) their pages. In response, there are web scraping systems that rely on using techniques in
DOM parsing,
computer vision
Computer vision is an Interdisciplinarity, interdisciplinary scientific field that deals with how computers can gain high-level understanding from digital images or videos. From the perspective of engineering, it seeks to understand and automate t ...
and
natural language processing
Natural language processing (NLP) is an interdisciplinary subfield of linguistics, computer science, and artificial intelligence concerned with the interactions between computers and human language, in particular how to program computers to proc ...
to simulate human browsing to enable gathering web page content for offline parsing.
History
The history of web scraping dates back nearly to the time when the World Wide Web was born.
* After the birth of the
World Wide Web in 1989, the first web robot,
World Wide Web Wanderer, was created in June 1993, which was intended only to measure the size of the web.
* In December 1993, the first crawler-based web search engine,
JumpStation, was launched. As there were fewer websites available on the web, search engines at that time used to rely on human administrators to collect and format links. In comparison, JumpStation was the first WWW search engine to rely on a web robot.
* In 2000, the first Web API and API crawler were created. An
API (Application Programming Interface) is an interface that makes it much easier to develop a program by providing the building blocks. In 2000,
Salesforce
Salesforce, Inc. is an American Cloud computing, cloud-based software company headquartered in San Francisco, California. It provides customer relationship management (CRM) software and applications focused on sales, customer service, marketi ...
and
eBay
eBay Inc. ( ) is an American multinational e-commerce company based in San Jose, California, that facilitates consumer-to-consumer and business-to-consumer sales through its website. eBay was founded by Pierre Omidyar in 1995 and became ...
launched their own API, with which programmers could access and download some of the data available to the public. Since then, many websites offer web APIs for people to access their public database.
Techniques
Web scraping is the process of automatically mining data or collecting information from the World Wide Web. It is a field with active developments sharing a common goal with the
semantic web vision, an ambitious initiative that still requires breakthroughs in text processing, semantic understanding, artificial intelligence and
human-computer interactions.
Human copy-and-paste
The simplest form of web scraping is manually copying and pasting data from a web page into a text file or spreadsheet. Sometimes even the best web-scraping technology cannot replace a human's manual examination and copy-and-paste, and sometimes this may be the only workable solution when the websites for scraping explicitly set up barriers to prevent machine automation.
Text pattern matching
A simple yet powerful approach to extract information from web pages can be based on the UNIX
grep
grep is a command-line utility for searching plain-text data sets for lines that match a regular expression. Its name comes from the ed command ''g/re/p'' (''globally search for a regular expression and print matching lines''), which has the sa ...
command or
regular expression
A regular expression (shortened as regex or regexp; sometimes referred to as rational expression) is a sequence of characters that specifies a search pattern in text. Usually such patterns are used by string-searching algorithms for "find" ...
-matching facilities of programming languages (for instance
Perl
Perl is a family of two High-level programming language, high-level, General-purpose programming language, general-purpose, Interpreter (computing), interpreted, dynamic programming languages. "Perl" refers to Perl 5, but from 2000 to 2019 it ...
or
Python).
HTTP programming
Static and
dynamic web pages can be retrieved by posting HTTP requests to the remote web server using
socket programming
Computer network programming involves writing computer programs that enable processes to communicate with each other across a computer network.
Connection-oriented and connectionless communications
Very generally, most of communications ca ...
.
HTML parsing
Many websites have large collections of pages generated dynamically from an underlying structured source like a database. Data of the same category are typically encoded into similar pages by a common script or template. In data mining, a program that detects such templates in a particular information source, extracts its content and translates it into a relational form, is called a
wrapper. Wrapper generation algorithms assume that input pages of a wrapper induction system conform to a common template and that they can be easily identified in terms of a URL common scheme. Moreover, some
semi-structured data query languages, such as
XQuery and the HTQL, can be used to parse HTML pages and to retrieve and transform page content.
DOM parsing
By embedding a full-fledged web browser, such as the
Internet Explorer
Internet Explorer (formerly Microsoft Internet Explorer and Windows Internet Explorer, commonly abbreviated IE or MSIE) is a series of graphical user interface, graphical web browsers developed by Microsoft which was used in the Microsoft Wind ...
or the
Mozilla
Mozilla (stylized as moz://a) is a free software community founded in 1998 by members of Netscape. The Mozilla community uses, develops, spreads and supports Mozilla products, thereby promoting exclusively free software and open standards, w ...
browser control, programs can retrieve the dynamic content generated by client-side scripts. These browser controls also parse web pages into a DOM tree, based on which programs can retrieve parts of the pages. Languages such as
Xpath
XPath (XML Path Language) is an expression language designed to support the query or transformation of XML documents. It was defined by the World Wide Web Consortium (W3C) and can be used to compute values (e.g., strings, numbers, or Boolean v ...
can be used to parse the resulting DOM tree.
Vertical aggregation
There are several companies that have developed vertical specific harvesting platforms. These platforms create and monitor a multitude of "bots" for specific verticals with no "man in the loop" (no direct human involvement), and no work related to a specific target site. The preparation involves establishing the knowledge base for the entire vertical and then the platform creates the bots automatically. The platform's robustness is measured by the quality of the information it retrieves (usually number of fields) and its scalability (how quick it can scale up to hundreds or thousands of sites). This scalability is mostly used to target the
Long Tail of sites that common aggregators find complicated or too labor-intensive to harvest content from.
Semantic annotation recognizing
The pages being scraped may embrace
metadata or semantic markups and annotations, which can be used to locate specific data snippets. If the annotations are embedded in the pages, as
Microformat does, this technique can be viewed as a special case of DOM parsing. In another case, the annotations, organized into a semantic layer, are stored and managed separately from the web pages, so the scrapers can retrieve data schema and instructions from this layer before scraping the pages.
Computer vision web-page analysis
There are efforts using
machine learning
Machine learning (ML) is a field of inquiry devoted to understanding and building methods that 'learn', that is, methods that leverage data to improve performance on some set of tasks. It is seen as a part of artificial intelligence.
Machine ...
and
computer vision
Computer vision is an Interdisciplinarity, interdisciplinary scientific field that deals with how computers can gain high-level understanding from digital images or videos. From the perspective of engineering, it seeks to understand and automate t ...
that attempt to identify and extract information from web pages by interpreting pages visually as a human being might.
Software
There are many software tools available that can be used to customize web-scraping solutions. This software may attempt to automatically recognize the data structure of a page or provide a recording interface that removes the necessity to manually write web-scraping code, or some scripting functions that can be used to extract and transform content, and database interfaces that can store the scraped data in local databases. Some web scraping software can also be used to extract data from an API directly.
Legal issues
The legality of web scraping varies across the world. In general, web scraping may be against the
terms of use of some websites, but the enforceability of these terms is unclear.
United States
In the United States, website owners can use three major
legal claims to prevent undesired web scraping: (1) copyright infringement (compilation), (2) violation of the
Computer Fraud and Abuse Act ("CFAA"), and (3)
trespass to chattel
Trespass to chattels is a tort whereby the infringing party has intentionally (or, in Australia, negligently) interfered with another person's lawful possession of a chattel (movable personal property). The interference can be any physical cont ...
. However, the effectiveness of these claims relies upon meeting various criteria, and the case law is still evolving. For example, with regard to copyright, while outright duplication of original expression will in many cases be illegal, in the United States the courts ruled in
''Feist Publications v. Rural Telephone Service'' that duplication of facts is allowable.
U.S. courts have acknowledged that users of "scrapers" or "robots" may be held liable for committing
trespass to chattels
Trespass to chattels is a tort whereby the infringing party has intentionally (or, in Australia, negligently) interfered with another person's lawful possession of a chattel (movable personal property). The interference can be any physical cont ...
, which involves a computer system itself being considered personal property upon which the user of a scraper is trespassing. The best known of these cases, ''
eBay v. Bidder's Edge'', resulted in an injunction ordering Bidder's Edge to stop accessing, collecting, and indexing auctions from the eBay web site. This case involved automatic placing of bids, known as
auction sniping. However, in order to succeed on a claim of trespass to
chattels, the
plaintiff
A plaintiff ( Π in legal shorthand) is the party who initiates a lawsuit (also known as an ''action'') before a court. By doing so, the plaintiff seeks a legal remedy. If this search is successful, the court will issue judgment in favor of the ...
must demonstrate that the
defendant
In court proceedings, a defendant is a person or object who is the party either accused of committing a crime in criminal prosecution or against whom some type of civil relief is being sought in a civil case.
Terminology varies from one juris ...
intentionally and without authorization interfered with the plaintiff's possessory interest in the computer system and that the defendant's unauthorized use caused damage to the plaintiff. Not all cases of web spidering brought before the courts have been considered trespass to chattels.
One of the first major tests of
screen scraping
Data scraping is a technique where a computer program extracts data from human-readable output coming from another program.
Description
Normally, data transfer between programs is accomplished using data structures suited for automated pro ...
involved
American Airlines
American Airlines is a major US-based airline headquartered in Fort Worth, Texas, within the Dallas–Fort Worth metroplex. It is the largest airline in the world when measured by fleet size, scheduled passengers carried, and revenue passenge ...
(AA), and a firm called FareChase. AA successfully obtained an
injunction from a Texas trial court, stopping FareChase from selling software that enables users to compare online fares if the software also searches AA's website. The airline argued that FareChase's websearch software trespassed on AA's servers when it collected the publicly available data. FareChase filed an appeal in March 2003. By June, FareChase and AA agreed to settle and the appeal was dropped.
Southwest Airlines has also challenged screen-scraping practices, and has involved both FareChase and another firm, Outtask, in a legal claim. Southwest Airlines charged that the screen-scraping is Illegal since it is an example of "Computer Fraud and Abuse" and has led to "Damage and Loss" and "Unauthorized Access" of Southwest's site. It also constitutes "Interference with Business Relations", "Trespass", and "Harmful Access by Computer". They also claimed that screen-scraping constitutes what is legally known as "Misappropriation and Unjust Enrichment", as well as being a breach of the web site's user agreement. Outtask denied all these claims, claiming that the prevailing law, in this case, should be
US Copyright law and that under copyright, the pieces of information being scraped would not be subject to copyright protection. Although the cases were never resolved in the
Supreme Court of the United States
The Supreme Court of the United States (SCOTUS) is the highest court in the federal judiciary of the United States. It has ultimate appellate jurisdiction over all U.S. federal court cases, and over state court cases that involve a point ...
, FareChase was eventually shuttered by parent company
Yahoo!
Yahoo! (, styled yahoo''!'' in its logo) is an American web services provider. It is headquartered in Sunnyvale, California and operated by the namesake company Yahoo! Inc. (2017–present), Yahoo Inc., which is 90% owned by investment funds ma ...
, and Outtask was purchased by travel expense company Concur.
[Imperva (2011)]
Detecting and Blocking Site Scraping Attacks
Imperva white paper..
In 2012, a startup called 3Taps scraped classified housing ads from Craigslist. Craigslist sent 3Taps a cease-and-desist letter and blocked their IP addresses and later sued, in ''
Craigslist v. 3Taps
''Craigslist Inc. v. 3Taps Inc.'', 942 F.Supp.2d 962 (N.D. Cal. 2013) was a Northern District of California Court case in which the court held that sending a cease-and-desist letter and enacting an IP address block is sufficient notice of onlin ...
''. The court held that the cease-and-desist letter and IP blocking was sufficient for Craigslist to properly claim that 3Taps had violated the
Computer Fraud and Abuse Act.
Although these are early scraping decisions, and the theories of liability are not uniform, it is difficult to ignore a pattern emerging that the courts are prepared to protect proprietary content on commercial sites from uses which are undesirable to the owners of such sites. However, the degree of protection for such content is not settled and will depend on the type of access made by the scraper, the amount of information accessed and copied, the degree to which the access adversely affects the site owner's system and the types and manner of prohibitions on such conduct.
While the law in this area becomes more settled, entities contemplating using scraping programs to access a public web site should also consider whether such action is authorized by reviewing the terms of use and other terms or notices posted on or made available through the site. In a 2010 ruling in the ''
Cvent, Inc. v.
Eventbrite, Inc.'' In the United States district court for the eastern district of Virginia, the court ruled that the terms of use should be brought to the users' attention In order for a
browse wrap contract or license to be enforced. In a 2014 case, filed in the
United States District Court for the Eastern District of Pennsylvania, e-commerce site
QVC objected to the Pinterest-like shopping aggregator Resultly's 'scraping of QVC's site for real-time pricing data. QVC alleges that Resultly "excessively crawled" QVC's retail site (allegedly sending 200-300 search requests to QVC's website per minute, sometimes to up to 36,000 requests per minute) which caused QVC's site to crash for two days, resulting in lost sales for QVC. QVC's complaint alleges that the defendant disguised its web crawler to mask its source IP address and thus prevented QVC from quickly repairing the problem. This is a particularly interesting scraping case because QVC is seeking damages for the unavailability of their website, which QVC claims was caused by Resultly.
In the plaintiff's web site during the period of this trial, the terms of use link are displayed among all the links of the site, at the bottom of the page as most sites on the internet. This ruling contradicts the Irish ruling described below. The court also rejected the plaintiff's argument that the browse-wrap restrictions were enforceable in view of Virginia's adoption of the Uniform Computer Information Transactions Act (UCITA)—a uniform law that many believed was in favor on common browse-wrap contracting practices.
In ''
Facebook, Inc. v. Power Ventures, Inc.'', a district court ruled in 2012 that Power Ventures could not scrape Facebook pages on behalf of a Facebook user. The case is on appeal, and the
Electronic Frontier Foundation
The Electronic Frontier Foundation (EFF) is an international non-profit digital rights group based in San Francisco, California. The foundation was formed on 10 July 1990 by John Gilmore, John Perry Barlow and Mitch Kapor to promote Internet ...
filed a brief in 2015 asking that it be overturned. In ''
Associated Press v. Meltwater U.S. Holdings, Inc.
''Associated Press v. Meltwater U.S. Holdings, Inc.'' (S.D.N.Y. March 21, 2013) was a district court case in which the Associated Press (AP) brought suit against Meltwater Group in U.S. (Meltwater) for clipping and sharing news items under copyrigh ...
'', a court in the US held Meltwater liable for scraping and republishing news information from the Associated Press, but a court in the United Kingdom held in favor of Meltwater.
Internet Archive
The Internet Archive is an American digital library with the stated mission of "universal access to all knowledge". It provides free public access to collections of digitized materials, including websites, software applications/games, music ...
collects and distributes a significant number of publicly available web pages without being considered to be in violation of copyright laws.
European Union
In February 2006, the
Danish Maritime and Commercial Court (Copenhagen) ruled that systematic crawling, indexing, and deep linking by portal site of estate site does not conflict with Danish law or the database directive of the European Union.
In a February 2010 case complicated by matters of jurisdiction, Ireland's High Court delivered a verdict that illustrates the
inchoate state of developing case law. In the case of ''Ryanair Ltd v Billigfluege.de GmbH'', Ireland's High Court ruled
Ryanair's "
click-wrap A clickwrap or clickthrough agreement is a prompt that offers individuals the opportunity to accept or decline a digitally-mediated policy. Privacy policies, terms of service and other user policies, as well as copyright policies commonly employ t ...
" agreement to be legally binding. In contrast to the findings of the United States District Court Eastern District of Virginia and those of the Danish Maritime and Commercial Court, Justice
Michael Hanna ruled that the hyperlink to Ryanair's terms and conditions was plainly visible, and that placing the onus on the user to agree to terms and conditions in order to gain access to online services is sufficient to comprise a contractual relationship. The decision is under appeal in Ireland's Supreme Court.
On April 30, 2020, the French Data Protection Authority (CNIL) released new guidelines on web scraping. The CNIL guidelines made it clear that publicly available data is still personal data and cannot be repurposed without the knowledge of the person to whom that data belongs.
Australia
In Australia, the
Spam Act 2003
The ''Spam Act 2003'' (Cth) is an Act passed by the Australian Parliament in 2003 to regulate commercial e-mail and other types of commercial electronic messages. The Act restricts spam, especially e-mail spam and some types of phone spam, as ...
outlaws some forms of web harvesting, although this only applies to email addresses.
India
Leaving a few cases dealing with IPR infringement, Indian courts have not expressly ruled on the legality of web scraping. However, since all common forms of electronic contracts are enforceable in India, violating the terms of use prohibiting data scraping will be a violation of the contract law. It will also violate the
Information Technology Act, 2000, which penalizes unauthorized access to a computer resource or extracting data from a computer resource.
Methods to prevent web scraping
The administrator of a website can use various measures to stop or slow a bot. Some techniques include:
* Blocking an
IP address
An Internet Protocol address (IP address) is a numerical label such as that is connected to a computer network that uses the Internet Protocol for communication.. Updated by . An IP address serves two main functions: network interface ident ...
either manually or based on criteria such as
geolocation
Geopositioning, also known as geotracking, geolocalization, geolocating, geolocation, or geoposition fixing, is the process of determining or estimating the geographic position of an object.
Geopositioning yields a set of geographic coordinates ...
and
DNSRBL. This will also block all browsing from that address.
* Disabling any
web service API that the website's system might expose.
* Bots sometimes declare who they are (using
user agent
In computing, a user agent is any software, acting on behalf of a user, which "retrieves, renders and facilitates end-user interaction with Web content". A user agent is therefore a special kind of software agent.
Some prominent examples of u ...
string
String or strings may refer to:
*String (structure), a long flexible structure made from threads twisted together, which is used to tie, bind, or hang other objects
Arts, entertainment, and media Films
* ''Strings'' (1991 film), a Canadian anim ...
s) and can be blocked on that basis using
robots.txt; '
googlebot' is an example. Other bots make no distinction between themselves and a human using a browser.
* Bots can be blocked by monitoring excess traffic
* Bots can sometimes be blocked with tools to verify that it is a real person accessing the site, like a
CAPTCHA
A CAPTCHA ( , a contrived acronym for "Completely Automated Public Turing test to tell Computers and Humans Apart") is a type of challenge–response test used in computing to determine whether the user is human.
The term was coined in 2003 b ...
. Bots are sometimes coded to explicitly break specific CAPTCHA patterns or may employ third-party services that utilize human labor to read and respond in real-time to CAPTCHA challenges.
* Commercial anti-bot services: Companies offer anti-bot and anti-scraping services for websites. A few web
application firewalls have limited bot detection capabilities as well. However, many such solutions are not very effective.
[Mayank Dhima]
Breaking Fraud & Bot Detection Solutions
''OWASP AppSec Cali' 2018'' Retrieved February 10, 2018.
* Locating bots with a
honeypot or other method to identify the IP addresses of automated crawlers.
*
Obfuscation
Obfuscation is the obscuring of the intended meaning of communication by making the message difficult to understand, usually with confusing and ambiguous language. The obfuscation might be either unintentional or intentional (although intent u ...
using
CSS sprites to display such data as telephone numbers or email addresses, at the cost of
accessibility to
screen reader users.
* Because bots rely on consistency in the front-end code of a target website, adding small variations to the HTML/CSS surrounding important data and navigation elements would require more human involvement in the ini