Applications of ChatGPT and other large language models in web scraping
Tags: ai, webscraping, chatgpt
Published: 2023-02-16 17:12:03

---
title: Applications of ChatGPT and other large language models in web scraping
published: true
date: 2023-02-08 17:05:26 UTC
tags: AI, webscraping, chatgpt
canonical_url: https://blog.apify.com/chatgpt-web-scraping/
---

Many people are wondering and (un)happily speculating on when and how large language models will change their work and industry. So what about AI and web scraping?

ChatGPT is an inexhaustible topic these days, making wave after wave on social media, news, and at our dinner table debates. Many people are wondering and (un)happily speculating on when and how large language models will change their work and industry. So what about AI and web scraping? There have already been a few interesting hands-on demonstrations [here](https://medium.com/codingthesmartway-com-blog/how-to-use-chatgpt-to-fully-automate-web-scraping-6bb0dab97943) and [there](https://www.youtube.com/watch?v=IMccv8xbguE) on how ChatGPT can be applied to web scraping.

In this article, well take a look at various use cases of large language models (ChatGPT specifically) in the context of web scraping, summarize what we know about it, and share some of our ideas on where else it can go.

## Trained on data scraped from web

Unsurprisingly, the web turns out to be the most convenient source for creating/curating datasets to feed AI models. These days, all large language models (LLMs) from Googles [PaLM](https://ai.googleblog.com/2022/04/pathways-language-model-palm-scaling-to.html) to DeepMinds [Gopher](https://www.deepmind.com/blog/language-modelling-at-scale-gopher-ethical-considerations-and-retrieval) are trained on data scraped from the web. For instance, the GPT-3 model, on which the ChatGPT is based, [was trained](https://lifearchitect.ai/models/) on data from the Internet Archive, Library Genesis (Libgen), Wikipedia, CommonCrawl, Google Patents, GitHub, and more.

Similarly, even image models like Stable Diffusion [are trained](https://www.dazeddigital.com/art-photography/article/57996/1/what-ai-image-scraping-how-can-artists-fight-back-meta-getty-stable-diffusion) from image and text data scraped from the web, such as LAION-5B and CommonCrawl. Not to mention the regular robots (with arms and legs) that are trained to respond by data extracted from the web like [the one in Google](https://www.wired.com/story/google-robot-learned-to-take-orders-by-scraping-the-web/).

Of course, the training datasets are highly curated and limited to a certain period in time. But they are scraped from the web. So if all this data is so easily accessible, are we on the brink of being able to build our own AI models? Well, kind of, but not in the way youd expect it.

## 🔬Train smaller models using custom-scraped data

Generally speaking, training large general-purpose LLMs is extremely expensive, in every way. To start with, training ChatGPT, for instance, [requires a supercomputer](https://news.microsoft.com/source/features/ai/openai-azure-supercomputer/) called Azure AI with a capacity of more than 285,000 CPU cores, 10,000 GPUs, and 400 gigabits/second of network connectivity for each GPU server.

Large datasets are also an important factor, but not so much because of size (the amount of data fed to the model does not directly correlate with its efficiency). What takes up the most resources is cleaning up the training data, labeling it, preparing and testing the models, and then running the training. A few PhDs in data science here would help a lot, as well as anywhere from a few months to a few years for the whole process to take shape, depending on the complexity of your model.

Besides, if you make a mistake in the training dataset, you might have to start over again. When OpenAI found an error in GPT-3 training data only after the model was trained, they decided it would be [too expensive to retrain](https://towardsdatascience.com/meet-m6-10-trillion-parameters-at-1-gpt-3s-energy-cost-997092cbe5e8). Keep in mind that training GPT-3 was estimated to cost anywhere from [$4.6M](https://heits.digital/articles/gpt3-overview) to [$12M](https://link.springer.com/article/10.1007/s11023-020-09548-1).

![animated graphic showing how 540 billion parameters come together for AI training](https://lh3.googleusercontent.com/8_IF2sGDDeIGmW34D6ACf_63ipSQR13iX_K3BHSCLGX7RQ4uoDBItm-BJBoty2Knre5A34JhjRVXaZuQqO8TwfYhdrwWMENoAhICWDVodLzCVxoJACBIFIOvRRgqqgW5RULZbgFiRPjDX95FusicY7I)

_Source:_ [_Google Blog_](https://ai.googleblog.com/2022/04/pathways-language-model-palm-scaling-to.html)

![Schematic explanation of how ChatGPT was trained from OpenAI](https://lh4.googleusercontent.com/a_sloxIN2WqaOB5SK17QiySKLr0-lauUTU13XaVxbdeHAFtXXpjCy_YLwEX5SNVQuvZDn3IU5SvMSQSbwxpTWVFosRMJCg7THgzAA_7LlQhqiPlHzNDqHV4L8G86_2fv2rtnA_V3VpMVKo5tki5CO5Y)

_Source:_ [_OpenAI_](https://openai.com/blog/chatgpt/)

So besides finding the right people for the job, and a ton of data, AI model training requires a ton of GPUs, and a lot of time for data collection, curation, and the training process itself. That already sounds intimidating and costly.

However, what about training a smaller-scale language model for a specific domain or case? Lets say for medical or legal texts. This is far more feasible. In addition, these models can be expected to be more precise, turning their limitations into their biggest advantage. At this moment in time, you can already use [nanoGPT](https://github.com/karpathy/nanoGPT) to train locally for specific cases, and new use cases are emerging.

Another option is to use a pre-trained language model and fine-train it on a more specific dataset. This invites us to consider a completely new level of ideas on the IT market, described by tech futurist [Shelly Palmer](https://www.shellypalmer.com/2022/12/ai-hiding-in-plain-sight/):

> 💬 One of the biggest opportunities for value creation in the next few years will be companies that leverage the base layers provided by large language models and finely tune highly-specialized middle layers above them. Think of it as training (educating) workers, then renting them out to other companies.
> 
> **The startup thesis for 2023?** Find an existing problem or inefficiency you can solve by fine-tuning a large language model, then turn the solution into a SaaS.

These solutions can be offered externally as a service, or used by the company internally to improve its product or workflow. By training and then integrating those specifically trained wrap models into their databases, platforms, CRMs via APIs, companies can reach or offer the level of automation they aspire to. But this is just the tip of the iceberg.

For example, there are new projects that answer questions about startups using data scraped from [Y Combinator public library](https://twitter.com/oralabs_/status/1620464421691850752) or [generate customer support questions](https://medium.com/@johnnythedeveloper/creating-a-customer-service-chatbot-with-chatgpt-5a6422e62f95) using the company knowledge base. Training data for fine-tuning such a model can be extracted using web scraping. Tools such as Apifys [Web Scraper](https://apify.com/apify/web-scraper) can be used to crawl the content of an entire domain in order to generate a dataset for such use cases and beyond.

## 🔎 Analyze scraped web content for semantics

Also known as [next-level googling](https://www.bvp.com/atlas/entering-the-era-of-intelligent-search). Not only can ChatGPT make a search more natural and conversational sounding, it is also great at text summarizing or extracting specific information you need which is what a lot of people expect from a search engine these days. [Google is already code-red worried](https://www.nytimes.com/2022/12/21/technology/ai-chatgpt-google-search.html) about the context- and history-aware potential of ChatGPT (and understandably so). With Google search pages sprouting more elements with every new upgrade (usually ads), the accurate semantic search might become its most powerful competitor yet.

This brings us to our next point: processing externally provided texts (which is what ChatGPT is doing) is just the **next evolutionary step of web scraping**. If we scrape a web page, which is basically a bunch of text and structure, and summarize its content into some sort of analysis - weve got ourselves a web scraping use case.

Simple examples: give ChatGPT an article about a football match, and it will be [able to tell you who won](https://ftw.usatoday.com/lists/we-asked-chatgpt-to-predict-the-outcomes-of-college-bowl-games-and-things-got-weird); ask it for a price of a product on a website, and it will give you the exact specs. Now take it a step further: provide a thousand tweets, comments, articles, videos, and ask for a summary, preferably in some easily digestible visual form and youve got yourself **sentiment analysis done by AI.**

Currently, the steps between collecting all that social media data and presenting the sentiment summary are usually split between a few providers dealing with different sides of web data (scraping, cleaning, storing, analyzing, structuring, visualizing, etc.). But the web scraping market is increasingly moving towards unifying all these steps under one roof. DiffBot with its [Knowledge Graph](https://www.diffbot.com/products/knowledge-graph/) is just one example.

Other easy web scraping + AI examples include:

- Categorizing customer support queries from the discussion forum

- Making social media channels easier to navigate (Telegram, Discord, Twitter, Slack, etc.) theres a list of [Chrome extensions](https://github.com/stars/acheong08/lists/awesome-chatgpt) for this already

- Automated product detail extraction

- Automatic translation of scraped data

{% embed https://blog.apify.com/building-functional-ai-models-for-web-scraping/ %}

## Enhance ChatGPT prompts with live data from the web

You may think ChatGPT answers are so precise because it scrapes the answers directly from the web. This is not true, and you can check the cutoff date yourself by asking questions about recent news ChatGPT is [blind to the most recent history](https://twitter.com/DataChaz/status/1610556519531089921).

While ChatGPT has no _default_ connection to the web, some users [have noticed](https://twitter.com/goodside/status/1598253337400717313) it does have a mysterious flag enableBrowsing: false. You can enable it using an advanced [Chrome extension](https://github.com/qunash/chatgpt-advanced) to allow for web results. It seems like an experimental feature to give the model access to the web and enable it to answer questions with up-to-date data and/or train itself.

Perhaps in the future, ChatGPT or GPT-4 will be able to access the web on its own. But for now, it doesnt enable accessing the web, so the only way to scrape the data externally would be using a browser extension or some web scraping API like [Google Search Scraper from Apify](https://apify.com/apify/google-search-scraper). Ideally, the process would go as follows: write a query to Google, then scrape the top 10 results of Google Search Results Page, feed all the answers into ChatGPT, and ChatGPT would extract the answer from the text.

![Cutoff date for ChatGPT is 2021](https://lh6.googleusercontent.com/cxHv7xVFYvlqCkZKWHOeGMUNBkWlJXkeA-kGbLdN_6o12_irpOU5_0Pc61MN--qe8IdrSow6iEquys2JGOc_TX9UVUh1_Ps7-r-9ZBimCF8JtAnSk3pHAXSXP2uCRX9a8vUR0jQOFvV3FpfwgE2PEMo)

_Source:_ [_Twitter_](https://twitter.com/DataChaz/status/1610556519531089921)

## 💾 **Use language models to generate web scraping code**

GPT-3, GitHub Copilot, Notion AI, and other similar models are trained on open-source code, which means they can also generate code in different programming languages, explain it, write comments, emulate a terminal, or generate API code.

This means ChatGPT can also generate code to scrape websites **using natural language to make a scraper.** Or at least generate some boilerplate code.

![Building a Wikipedia scraper using Selenium](https://lh3.googleusercontent.com/xqVOXHixMwRXi6HD4tEy65nD14aS9FmATtAluw-vaZDkck5hQPTDv3kcBh1Uq9gVCw3ieaU9WWGYhM6o2bOPpg9dres2ItHbI0PaA-WWBojKoeykHaDUZGp_U6vE-QrCDQdM8qx6nWGmSx-Kr8z92Ok)

_Source:_ [_Twitter_](https://twitter.com/he_yi_hui/status/1617328366876786688)

![An article about scraping with ChatGPT, with examples](https://blog.apify.com/content/images/2023/02/Screenshot-2023-02-02-at-14.11.27.png)

_Source:_ [_Medium_](https://medium.com/geekculture/i-found-a-loophole-to-successfully-web-scrape-using-chatgpt-heres-how-it-works-135f6c077d4d)

There have already been several attempts at this, but the scraping code generated is still on a very basic level. Every year, web scraping is getting ever more complicated, due to sophisticated blocking techniques, using proxies, browser fingerprints, etc. ChatGPT doesnt know these tricks well yet, so the resulting scrapers such as [this one written in Python](https://www.linkedin.com/pulse/web-scraping-experts-ai-stealing-our-job-pierluigi-vinciguerra/) though impressive are insufficient for now. So they will not replace human developers quite yet.

In fact, ChatGPTs code sometimes provides code so wrong its the reason [Stack Overflow](https://meta.stackoverflow.com/questions/421831/temporary-policy-chatgpt-is-banned) banned the publication of ChatGPT-generated code on its website.

> 💬 The primary problem is that while the **answers which ChatGPT produces have a high rate of being incorrect, they typically look like they might be good** and the answers are very easy to produce. There are also many people trying out ChatGPT to create answers, without the expertise or willingness to verify that the answer is correct prior to posting.
> 
> The volume of these answers (thousands) and the fact that the answers often require a detailed read by someone with at least some subject matter expertise in order to determine that the answer is actually bad has effectively swamped our volunteer-based quality curation infrastructure.

## Generate web content using ChatGPT

This is not exactly related to web scraping, but will surely be a big part of applying ChatGPT. While ChatGPT is [not sentient](https://www.theguardian.com/technology/2022/jul/23/google-fires-software-engineer-who-claims-ai-chatbot-is-sentient) (its just well-programmed to predict the next most probable word in a sequence), it does respond both correctly and confidently. So clearly, LLMs and other models will be used to generate a lot of marketing content on the web.

- Generating product descriptions for e-commerce websites

- Abstracting text

- Creating social media captions

- Suggesting content plans, topics, briefs, and outlines for blog posts

- Brainstorming naming or startup ideas

But the most enthusiastic users should be aware that OpenAI provides tools to [detect AI-generated text](https://openai.com/blog/new-ai-classifier-for-indicating-ai-written-text/), so websites containing generated content might get banned or ranked down by search engines. In addition, OpenAI is working on [introducing a watermark](https://techcrunch.com/2022/12/10/openais-attempts-to-watermark-ai-text-hit-limits/?guccounter=1&guce_referrer=aHR0cHM6Ly93d3cuZ29vZ2xlLmNvbS8&guce_referrer_sig=AQAAAHGWX7AlcCyKipkEtf3f_s4hDEBkk1_aizmbnXiZKuzpLjp4qjlhz82fFY62SFBQVLRGgHy1L6AKarxAAF2rzqzAwxN5cW-puCZM51EiNYvq7UZsNXDGAH3ne_QhdMeOi2ySCeiL8W0PB43a9CUVi0ZBEFW5GKgqNcBFw03yNhTC).

![Illustration of a robot in a stained glass, image generated by Midjourney](https://blog.apify.com/content/images/2023/02/vroomvroomvroom_cartoony_friendly_helpful_robot_in_stained_glas_c09cf0a6-9942-495a-889b-f8627dd90f20.png)

_This image was generated by Midjourney_

## 🌍 Ask philosophical questions

This last point invites a philosophical question: if more and more content on the web is generated using AI, and then we train new AI models using that text, will it actually get smarter, or just more confident about incorrect conclusions? This is also known as data incest in statistics.

And while there are a [lot of ways to trick](https://twitter.com/jmilldotdev/status/1600624362394091523) it or turn it to the dark side by wrapping the query into a function, for instance, can that dark side also be leveraged by wrongdoers? In fact, Evil ChatGPT is already used by cybersecurity specialists for training.

![An example of an extensive hacking command for ChatGPT](https://lh3.googleusercontent.com/9ozSlFzIZ7I5EtoGy76Bj1bTI_kuy7sE8yL6gZ903QNVKtEXXxyQLHxGulnQlwTS3j991g9MMYqrTw3DuXzl_bqvQbpdhKVm69d2Y-PhP9njBGYX8hbbyyzttseBxvhzlH-0cZqG3Wqy_KKYJR4b_P4)

_Source:_ [_Twitter_](https://twitter.com/jmilldotdev/status/1600624362394091523)

![How ChatGPT can be used for Cybersecurity](https://lh3.googleusercontent.com/qaWHla05CvL_YHdKW2YKM8GmoHDWl6fMadHUO1SzmrAt6AwaZnh2LaZBhHCQXM-BstzU14BHhIx1m9v9oNXnPEfCx2egN0o8raGT65sPhO0SErhpocjivnAiWzlsiYdLDzNjhd6d12D7X_ghq2jjGUE)

_Source:_ [_LinkedIn_](https://www.linkedin.com/in/matthieu-garin-3336481?miniProfileUrn=urn%3Ali%3Afs_miniProfile%3AACoAAABF09cBV8SxQpfKMC_4DtEfRLTp7_RH7H8&lipi=urn%3Ali%3Apage%3Ad_flagship3_detail_base%3BArtRwXmORNSBRRwbrFj%2BoA%3D%3D)

Another one: [would you enjoy a movie knowing it was 100% created by a robot?](https://substack.piszek.com/p/ai-free) Theres some sentiment about the declining value of work (both content and code) if it was produced by an AI. And what if AI was only partially involved? Or if you didn't know?

While were also scratching our heads trying to find answers, you can take a look at:

- this most imaginative list of [100 use cases for ChatGPT](https://becominghuman.ai/unlocking-the-power-of-the-chatgpt-revolution-100-use-cases-to-try-before-you-are-fired-979e5986814c) both interesting and entertaining.

- this extensive [overview](https://lifearchitect.ai/chatgpt/) of publicly available large language models.

- last but not least, check out the [interview](https://www.theverge.com/23560328/openai-gpt-4-rumor-release-date-sam-altman-interview) of OpenAIs CEO, Sam Altman, which addresses a lot of the rumors and misunderstandings surrounding ChatGPT-4.

{% embed https://blog.apify.com/future-of-web-scraping-in-2023/ %}