Web scraping explained

Web scraping, web harvesting, or web data extraction is data scraping used for extracting data from websites.[1] Web scraping software may directly access the World Wide Web using the Hypertext Transfer Protocol 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 or web crawler. It is a form of copying in which specific data is gathered and copied from the web, typically into a central local database or spreadsheet, for later retrieval or analysis.

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, 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 and XHTML), and frequently contain a wealth of useful data in text form. However, most web pages are designed for human end-users and not for ease of automated use. As a result, specialized tools and software have been developed to facilitate the scraping of web pages. Web scraping applications include market research, price comparison, content monitoring, and more. Businesses rely on web scraping services to efficiently gather and utilize this data.

Newer forms of web scraping involve monitoring data feeds from web servers. For example, JSON is commonly used as a transport 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 and natural language processing to simulate human browsing to enable gathering web page content for offline parsing

History

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 command or regular expression-matching facilities of programming languages (for instance Perl or Python).

HTTP programming

Static and dynamic web pages can be retrieved by posting HTTP requests to the remote web server using socket programming.

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.[3] 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 or the Mozilla 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 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,[4] 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 and computer vision that attempt to identify and extract information from web pages by interpreting pages visually as a human being might.[5]

AI-powered document understanding

Uses advanced AI to interpret and process web page content contextually, extracting relevant information, transforming data, and customizing outputs based on the content's structure and meaning. This method enables more intelligent and flexible data extraction, accommodating complex and dynamic web content.

Software

The world of web scraping offers a variety of software tools designed to simplify and customize the process of data extraction from websites. These tools vary in their approach and capabilities, making web scraping accessible to both novice users and advanced programmers.

Some advanced web scraping software can automatically recognize the data structure of a web page, eliminating the need for manual coding. Others provide a recording interface that allows users to record their interactions with a website, thus creating a scraping script without writing a single line of code. Many tools also include scripting functions for more customized extraction and transformation of content, along with database interfaces to store the scraped data locally.

Web scraping tools are versatile in their functionality. Some can directly extract data from APIs, while others are capable of handling websites with AJAX-based dynamic content loading or login requirements. Point-and-click software, for instance, empowers users without advanced coding skills to benefit from web scraping. This democratizes access to data, making it easier for a broader audience to leverage the power of web scraping.

Popular Web Scraping Tools

BeautifulSoup: A Python library that provides simple methods for extracting data from HTML and XML files.

Scrapy: An open-source and collaborative web crawling framework for Python that allows you to extract the data, process it, and store it.

Octoparse: A no-code web scraping tool that offers a user-friendly interface for extracting data from websites without needing programming skills.

ParseHub: Another no-code web scraper that can handle dynamic content and works with AJAX-loaded sites.

Apify: A platform that offers a wide range of scraping tools and the ability to create custom scrapers.

InstantAPI.ai: An AI-powered tool that transforms any web page into personalized APIs instantly, offering advanced data extraction and customization.

Web Scraping Platforms

Some platforms provide not only tools for web scraping but also opportunities for developers to share and potentially monetize their scraping solutions. By leveraging these tools and platforms, users can unlock the full potential of web scraping, turning raw data into valuable insights and opportunities.

[6]

Legal issues

The legality of web scraping varies across the world. In general, web scraping may be against the terms of service of some websites, but the enforceability of these terms is unclear.[7]

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.[8] 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,[9] [10] 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 must demonstrate that the defendant 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.[11]

One of the first major tests of screen scraping involved American Airlines (AA), and a firm called FareChase.[12] 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.[13]

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, FareChase was eventually shuttered by parent company Yahoo!, and Outtask was purchased by travel expense company Concur.[14] 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. 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 (CFAA).

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.[15]

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.[16] In a 2014 case, filed in the United States District Court for the Eastern District of Pennsylvania,[17] 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.[18] 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.[19]

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 filed a brief in 2015 asking that it be overturned.[20] [21] In Associated Press v. Meltwater U.S. Holdings, Inc., 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.

The Ninth Circuit ruled in 2019 that web scraping did not violate the CFAA in hiQ Labs v. LinkedIn. The case was appealed to the United States Supreme Court, which returned the case to the Ninth Circuit to reconsider the case in light of the 2021 Supreme Court decision in Van Buren v. United States which narrowed the applicability of the CFAA.[22] On this review, the Ninth Circuit upheld their prior decision.[23]

Internet Archive 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 real estate site does not conflict with Danish law or the database directive of the European Union.[24]

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" 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.[25] The decision is under appeal in Ireland's Supreme Court.[26]

On April 30, 2020, the French Data Protection Authority (CNIL) released new guidelines on web scraping.[27] 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.[28]

Australia

In Australia, the Spam Act 2003 outlaws some forms of web harvesting, although this only applies to email addresses.[29] [30]

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:

See also

Notes and References

  1. Thapelo . Tsaone Swaabow . Namoshe . Molaletsa . Matsebe . Oduetse . Motshegwa . Tshiamo . Bopape . Mary-Jane Morongwa . 2021-07-28 . SASSCAL WebSAPI: A Web Scraping Application Programming Interface to Support Access to SASSCAL's Weather Data . Data Science Journal . en . 20 . 24 . 10.5334/dsj-2021-024 . 237719804 . 1683-1470 . free .
  2. Web site: Search Engine History.com . Search Engine History . November 26, 2019.
  3. Book: Song, Ruihua. Microsoft Research. Proceedings of the 13th ACM SIGKDD international conference on Knowledge discovery and data mining . Joint optimization of wrapper generation and template detection . https://pdfs.semanticscholar.org/4fb4/3c5a212df751e84c3b2f8d29fabfe56c3616.pdf. https://web.archive.org/web/20161011080619/https://pdfs.semanticscholar.org/4fb4/3c5a212df751e84c3b2f8d29fabfe56c3616.pdf. dead. October 11, 2016. Sep 14, 2007. 894. 10.1145/1281192.1281287. 9781595936097. 833565.
  4. http://www.gooseeker.com/en/node/knowledgebase/freeformat Semantic annotation based web scraping
  5. Web site: Diffbot Is Using Computer Vision to Reinvent the Semantic Web. 2013-03-15. Wade. Roush. 2012-07-25. www.xconomy.com.
  6. Ciechanowski . Leon . Jemielniak . Dariusz . Gloor . Peter A. . TUTORIAL: AI research without coding: The art of fighting without fighting: Data science for qualitative researchers . Journal of Business Research . Elsevier BV . 117 . 2020 . 0148-2963 . 10.1016/j.jbusres.2020.06.012 . 322–330. free .
  7. Web site: FAQ about linking – Are website terms of use binding contracts?. 2007-08-20. 2007-08-20. www.chillingeffects.org. https://web.archive.org/web/20020308222536/http://www.chillingeffects.org/linking/faq.cgi#QID596. 2002-03-08. dead.
  8. Kenneth. Hirschey, Jeffrey. 2014-01-01. Symbiotic Relationships: Pragmatic Acceptance of Data Scraping. Berkeley Technology Law Journal. 29. 4. 10.15779/Z38B39B. 1086-3818.
  9. Web site: Internet Law, Ch. 06: Trespass to Chattels. 2007-08-20. 2007-08-20. www.tomwbell.com.
  10. Web site: What are the "trespass to chattels" claims some companies or website owners have brought?. 2007-08-20. 2007-08-20. www.chillingeffects.org. https://web.archive.org/web/20020308222536/http://www.chillingeffects.org/linking/faq.cgi#QID460. 2002-03-08. dead.
  11. Web site: Ticketmaster Corp. v. Tickets.com, Inc.. 2007-08-20. 2007-08-20.
  12. Web site: American Airlines v. FareChase. 2007-08-20. 2007-08-20. https://web.archive.org/web/20110723131832/http://www.fornova.net/documents/AAFareChase.pdf. 2011-07-23. dead.
  13. Web site: American Airlines, FareChase Settle Suit.. 2012-02-26. 2003-06-13. The Free Library. 2016-03-05. https://web.archive.org/web/20160305025808/http://www.thefreelibrary.com/American+Airlines,+FareChase+Settle+Suit.-a0103213546. dead.
  14. Imperva (2011). Detecting and Blocking Site Scraping Attacks. Imperva white paper.
  15. Web site: Controversy Surrounds 'Screen Scrapers': Software Helps Users Access Web Sites But Activity by Competitors Comes Under Scrutiny. 2010-10-27. Kenneth A.. Adler. 2003-07-29. https://web.archive.org/web/20110211123854/http://library.findlaw.com/2003/Jul/29/132944.html. 2011-02-11.
  16. Web site: QVC Inc. v. Resultly LLC, No. 14-06714 (E.D. Pa. filed Nov. 24, 2014). 2015-11-05. 2014-11-24. 2013-09-21. https://web.archive.org/web/20130921054619/http://www.fornova.net/documents/Cvent.pdf. dead.
  17. Web site: QVC Inc. v. Resultly LLC, No. 14-06714 (E.D. Pa. filed Nov. 24, 2014). United States District Court for the Eastern District of Pennsylvania. 5 November 2015.
  18. Neuburger. Jeffrey D. QVC Sues Shopping App for Web Scraping That Allegedly Triggered Site Outage. The National Law Review. 5 December 2014. 5 November 2015. Proskauer Rose LLP.
  19. Web site: Did Iqbal/Twombly Raise the Bar for Browsewrap Claims?. 2010-10-27. 2010-09-17. 2011-07-23. https://web.archive.org/web/20110723132015/http://www.fornova.net/documents/pblog-bna-com.pdf. dead.
  20. Web site: Can Scraping Non-Infringing Content Become Copyright Infringement... Because Of How Scrapers Work? Techdirt. 2009-06-10. Techdirt.. 2016-05-24.
  21. Web site: Facebook v. Power Ventures. Electronic Frontier Foundation. 2016-05-24.
  22. Web site: U.S. Supreme Court revives LinkedIn bid to shield personal data . Andrew . Chung . June 14, 2021 . June 14, 2021 . .
  23. Web site: Whittaker . Zack . Web scraping is legal, US appeals court reaffirms . TechCrunch . 18 April 2022.
  24. Web site: UDSKRIFT AF SØ- & HANDELSRETTENS DOMBOG. 2007-05-30. 2006-02-24. bvhd.dk. dead. https://web.archive.org/web/20071012005033/http://www.bvhd.dk/uploads/tx_mocarticles/S_-_og_Handelsrettens_afg_relse_i_Ofir-sagen.pdf. 2007-10-12. da.
  25. Web site: High Court of Ireland Decisions >> Ryanair Ltd -v- Billigfluege.de GMBH 2010 IEHC 47 (26 February 2010). 2010-02-26. British and Irish Legal Information Institute. 2012-04-19.
  26. Web site: Intellectual Property: Website Terms of Use. June 2010. LK Shields Solicitors Update. Issue 26: June 2010. 03. Áine. Matthews. 2012-04-19. 2012-06-24. https://web.archive.org/web/20120624103316/http://www.lkshields.ie/htmdocs/publications/newsletters/update26/update26_03.htm. dead.
  27. Web site: La réutilisation des données publiquement accessibles en ligne à des fins de démarchage commercial CNIL. 2020-07-05. www.cnil.fr. fr.
  28. Web site: FindDataLab.com. 2020-06-09. Can You Still Perform Web Scraping With The New CNIL Guidelines?. 2020-07-05. Medium. en.
  29. Web site: Spam Act 2003: An overview for business. 2017-12-07. National Office for the Information Economy. February 2004. Australian Communications Authority. 6. 2019-12-03. https://web.archive.org/web/20191203113701/https://www.lloyds.com/~/media/5880dae185914b2487bed7bd63b96286.ashx. dead.
  30. Web site: Spam Act 2003: A practical guide for business. 2017-12-07 . National Office for the Information Economy. February 2004. Australian Communications Authority. 20.
  31. Web site: 2023-08-31 . Web Scraping for Beginners: A Guide 2024 . 2024-03-15 . Proxyway . en-US.
  32. Mayank Dhiman Breaking Fraud & Bot Detection Solutions OWASP AppSec Cali' 2018 Retrieved February 10, 2018.