{"id":9379,"date":"2024-02-26T17:07:30","date_gmt":"2024-02-27T01:07:30","guid":{"rendered":"https:\/\/live-cometml.pantheonsite.io\/?p=9379"},"modified":"2025-04-24T17:03:07","modified_gmt":"2025-04-24T17:03:07","slug":"top-5-web-scraping-methods-including-using-llms","status":"publish","type":"post","link":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/","title":{"rendered":"Top 5 Web Scraping Methods: Including Using LLMs"},"content":{"rendered":"\n<section class=\"section section--body\">\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<\/div><\/div><\/section>\n\n\n\n<figure class=\"wp-block-image aligncenter wp-image-9390 size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"7734\" height=\"5159\" src=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash.jpg\" alt=\"\" class=\"wp-image-9390\" srcset=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash.jpg 7734w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash-300x200.jpg 300w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash-1024x683.jpg 1024w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash-768x512.jpg 768w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash-1536x1025.jpg 1536w\" sizes=\"auto, (max-width: 7734px) 100vw, 7734px\" \/><figcaption class=\"wp-element-caption\">Photo by <a href=\"https:\/\/unsplash.com\/@nate_dumlao?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash\">Nathan Dumlao<\/a> on <a href=\"https:\/\/unsplash.com\/photos\/spider-web-in-close-up-photography-kME9jbKd--s?utm_content=creditCopyText&amp;utm_medium=referral&amp;utm_source=unsplash\">Unsplash<\/a><\/figcaption><\/figure>\n\n\n\n<h2 class=\"wp-block-heading graf graf--h3\">Introduction<\/h2>\n\n\n\n<p class=\"graf graf--p\">Web scraping automates the extraction of data from websites using programming or specialized tools. Required for tasks such as market research, data analysis, content aggregation, and competitive intelligence. This efficient method saves time, improves decision making, and allows businesses to study trends and patterns, making it a powerful tool for extracting valuable information from the Internet.<\/p>\n\n\n\n<p class=\"graf graf--p\">Since I received a lot of positive comments on my last article, I would like to delve into this topic that is of interest to many people. Besides <strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">BeautifulSoup, Scrapy, and Selenium<\/em><\/strong>, have you considered web scraping using <strong class=\"markup--strong markup--p-strong\">LLM<\/strong>? It\u2019s a technique worthy of your curiosity.<\/p>\n\n\n\n<figure class=\"graf graf--figure\">\n<\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter graf-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*sFV53FmQNtgXPOoHeBHtlw.png\" alt=\"Top five web scraping methods, including usings LLMs with CometLLM\"\/><figcaption class=\"wp-element-caption\">Top five web scraping methods (Image by the author)<\/figcaption><\/figure>\n\n\n\n<blockquote class=\"wp-block-quote graf graf--blockquote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>\ud83d\udca1I write about Machine Learning on <a class=\"markup--anchor markup--blockquote-anchor\" href=\"https:\/\/medium.com\/@yennhi95zz\/subscribe\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/medium.com\/@yennhi95zz\/subscribe\">Medium<\/a> || <a class=\"markup--anchor markup--blockquote-anchor\" href=\"https:\/\/github.com\/yennhi95zz\" target=\"_blank\" rel=\"noopener ugc nofollow\" data-href=\"https:\/\/github.com\/yennhi95zz\">Github<\/a> || <a class=\"markup--anchor markup--blockquote-anchor\" href=\"https:\/\/www.kaggle.com\/nhiyen\/code\" target=\"_blank\" rel=\"noopener ugc nofollow\" data-href=\"https:\/\/www.kaggle.com\/nhiyen\/code\">Kaggle<\/a> || <a class=\"markup--anchor markup--blockquote-anchor\" href=\"https:\/\/www.linkedin.com\/in\/yennhi95zz\/\" target=\"_blank\" rel=\"noopener ugc nofollow\" data-href=\"https:\/\/www.linkedin.com\/in\/yennhi95zz\/\">Linkedin<\/a>. \ud83d\udd14 Follow \u201cNhi Yen\u201d for future updates!<\/p>\n<\/blockquote>\n\n\n\n<section class=\"section section--body\">\n<div class=\"section-divider\"><\/div>\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<h4 class=\"graf graf--h3\">Let\u2019s start!!!<\/h4>\n<p class=\"graf graf--p\">If you know Python but not HTML, you should first understand the basics of HTML.<\/p>\n<h2 class=\"graf graf--h3\">I. Understanding Basic HTML for Web Scraping<\/h2>\n<p class=\"graf graf--p\">HTML is the basic component of web pages. A set of tags is used to structure content on the Internet. Tags are like containers that wrap various elements, defining their structure and appearance on a web page.<\/p>\n<\/div>\n<\/div><\/section>\n\n\n\n<figure class=\"wp-block-image aligncenter wp-image-9382 size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"2372\" height=\"696\" src=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.00.32\u202fPM.png\" alt=\"A diagram that breaks down HTML elements for web scraping\" class=\"wp-image-9382\" srcset=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.00.32\u202fPM.png 2372w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.00.32\u202fPM-300x88.png 300w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.00.32\u202fPM-1024x300.png 1024w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.00.32\u202fPM-768x225.png 768w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.00.32\u202fPM-1536x451.png 1536w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.00.32\u202fPM-2048x601.png 2048w\" sizes=\"auto, (max-width: 2372px) 100vw, 2372px\" \/><figcaption class=\"wp-element-caption\">HTML Elements (<a href=\"https:\/\/en.wikipedia.org\/wiki\/HTML_element\">Wikipedia<\/a>)<\/figcaption><\/figure>\n\n\n\n<div class=\"section-inner sectionLayout--insetColumn\">\n<h4 class=\"graf graf--h4\"><strong class=\"markup--strong markup--h4-strong\">1. Structure of&nbsp;HTML<\/strong><\/h4>\n<p class=\"graf graf--p\">An HTML document consists of 2 main parts: header and body.<\/p>\n<ul class=\"postList\">\n<li class=\"graf graf--li\"><strong class=\"markup--strong markup--li-strong\">The header<\/strong> contains metadata such as the page title and links to external resources.<\/li>\n<li class=\"graf graf--li\"><strong class=\"markup--strong markup--li-strong\">The body<\/strong> contains the content of the web page, including text, images, and other multimedia elements.<\/li>\n<\/ul>\n<p class=\"graf graf--p\">Here\u2019s a simple HTML template:<\/p>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"1\" data-code-block-lang=\"xml\"><span class=\"pre--content\"><span class=\"hljs-meta\">&lt;!DOCTYPE <span class=\"hljs-keyword\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">html<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">title<\/span>&gt;<\/span>My First Web Page<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">title<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">head<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">h1<\/span>&gt;<\/span>Hello, World!<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">h1<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">p<\/span>&gt;<\/span>This is a simple webpage.<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">p<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">body<\/span>&gt;<\/span>\n<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">html<\/span>&gt;<\/span><\/span><\/pre>\n<h4 class=\"graf graf--h4\">2. HTML&nbsp;Tags<\/h4>\n<p class=\"graf graf--p\">Tags are the heart of HTML. They define different elements on a webpage. Some common tags include:<\/p>\n<ul class=\"postList\">\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">&lt;h1&gt;<\/code> to <code class=\"markup--code markup--li-code\">&lt;h6&gt;<\/code>: Headings, with <code class=\"markup--code markup--li-code\">&lt;h1&gt;<\/code> being the largest and <code class=\"markup--code markup--li-code\">&lt;h6&gt;<\/code> the smallest.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">&lt;p&gt;<\/code>: Paragraphs of text.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">&lt;a&gt;<\/code>: Hyperlinks, allowing you to navigate to other pages.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">&lt;img&gt;<\/code>: Images.<\/li>\n<li class=\"graf graf--li\"><code class=\"markup--code markup--li-code\">&lt;ul&gt;<\/code>, <code class=\"markup--code markup--li-code\">&lt;ol&gt;<\/code>, <code class=\"markup--code markup--li-code\">&lt;li&gt;<\/code>: Lists, both unordered and ordered.<\/li>\n<\/ul>\n<h4 class=\"graf graf--h4\">3. Attributes:<\/h4>\n<p class=\"graf graf--p\">Attributes provide additional information about an HTML element. These are always included in the opening tag and specified as name\/value pairs. For example, the <code class=\"markup--code markup--p-code\">href<\/code> attribute in an <code class=\"markup--code markup--p-code\">&lt;a&gt;<\/code> tag defines the hyperlink&#8217;s destination.<\/p>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"1\" data-code-block-lang=\"xml\"><span class=\"pre--content\"><span class=\"hljs-tag\">&lt;<span class=\"hljs-name\">a<\/span> <span class=\"hljs-attr\">href<\/span>=<span class=\"hljs-string\">\"https:\/\/www.example.com\"<\/span>&gt;<\/span>Visit Example<span class=\"hljs-tag\">&lt;\/<span class=\"hljs-name\">a<\/span>&gt;<\/span><\/span><\/pre>\n<h4 class=\"graf graf--h4\">4. How to Inspect Elements in a&nbsp;Website<\/h4>\n<p class=\"graf graf--p\">Most web browsers provide built-in tools for inspecting elements. To open this tool, right-click the web page and select <strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">Inspect<\/em><\/strong>. Here you can view the HTML code and identify the tags containing the data you want to extract.<\/p>\n<\/div>\n\n\n\n<figure class=\"wp-block-image aligncenter wp-image-9387 size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1770\" height=\"1168\" src=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.11.29\u202fPM.png\" alt=\"\" class=\"wp-image-9387\" srcset=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.11.29\u202fPM.png 1770w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.11.29\u202fPM-300x198.png 300w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.11.29\u202fPM-1024x676.png 1024w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.11.29\u202fPM-768x507.png 768w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.11.29\u202fPM-1536x1014.png 1536w\" sizes=\"auto, (max-width: 1770px) 100vw, 1770px\" \/><figcaption class=\"wp-element-caption\">Inspect option in Google Chrome (Image by the Author)<\/figcaption><\/figure>\n\n\n\n<p class=\"graf graf--p\">Selectors help pinpoint specific elements on a webpage. Common selectors include:<\/p>\n\n\n\n<ul class=\"wp-block-list postList\">\n<li>Element Selector: <code class=\"markup--code markup--li-code\">element<\/code> selects all instances of the specified HTML element.<\/li>\n\n\n\n<li>Class Selector:\u00a0<code class=\"markup--code markup--li-code\">.class<\/code> selects all elements with the specified class.<\/li>\n\n\n\n<li>ID Selector: <code class=\"markup--code markup--li-code\">#id<\/code> selects a unique element with the specified ID.<\/li>\n<\/ul>\n\n\n\n<p class=\"graf graf--p\">For example:<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter wp-image-9388 size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"1970\" height=\"1060\" src=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.16.31\u202fPM.png\" alt=\"\" class=\"wp-image-9388\" srcset=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.16.31\u202fPM.png 1970w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.16.31\u202fPM-300x161.png 300w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.16.31\u202fPM-1024x551.png 1024w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.16.31\u202fPM-768x413.png 768w, https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/Screenshot-2024-02-26-at-7.16.31\u202fPM-1536x826.png 1536w\" sizes=\"auto, (max-width: 1970px) 100vw, 1970px\" \/><figcaption class=\"wp-element-caption\">Inspect IMDB website (Image by the Author)<\/figcaption><\/figure>\n\n\n\n<div class=\"section-inner sectionLayout--insetColumn\">\n<h3 class=\"graf graf--h3\">II. How to Scrape<\/h3>\n<h4 class=\"graf graf--h4\">\u2757Disclaimer<\/h4>\n<p class=\"graf graf--p\">This article is not about web scraping for illegal purposes. Make sure you have permission before extracting content. Ways to check include:<\/p>\n<ol class=\"postList\">\n<li class=\"graf graf--li\">Review the website\u2019s terms of use. Look for mentions of scraping permissions.<\/li>\n<li class=\"graf graf--li\">Use APIs when available. APIs provide legal access to data.<\/li>\n<li class=\"graf graf--li\">Please contact the website owner to clarify your permission directly.<\/li>\n<\/ol>\n<\/div>\n\n\n\n<section class=\"section section--body\">\n<div class=\"section-divider\"><\/div>\n<div class=\"section-content\">\n<div class=\"section-inner sectionLayout--insetColumn\">\n<p class=\"graf graf--p\">OK, assume you are aware of your actions. Let\u2019s start.<\/p>\n<p class=\"graf graf--p\">Here\u2019s the URL for <strong class=\"markup--strong markup--p-strong\">Action Movies of 2022<\/strong>: <a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/www.imdb.com\/list\/ls566941243\/\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/www.imdb.com\/list\/ls566941243\/\">https:\/\/www.imdb.com\/list\/ls566941243\/<\/a>. I\u2019ll use 05 different methods to scrape <code class=\"markup--code markup--p-code\">[\u2018Title\u2019, \u2018Genre\u2019, \u2018Stars\u2019, \u2018Runtime\u2019, \u2018Rating\u2019] <\/code>data from this website.<\/p>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"2\" data-code-block-lang=\"python\"><span class=\"pre--content\"><span class=\"hljs-comment\"># Define the URL<\/span>\nurl = <span class=\"hljs-string\">\"https:\/\/www.imdb.com\/list\/ls566941243\/\"<\/span><\/span><\/pre>\n<p class=\"graf graf--p\"><em class=\"markup--em markup--p-em\">\ud83d\udc49 You can find the entire code in this <\/em><strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">GitHub Repository<\/em><\/strong><em class=\"markup--em markup--p-em\">. To begin, please install the required Python packages listed in <\/em><strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">requirements.txt<\/em><\/strong><em class=\"markup--em markup--p-em\">.<\/em><\/p>\n<h3 class=\"graf graf--h3\">Method 1: BeautifulSoup and Requests for Web Scraping<\/h3>\n<p class=\"graf graf--p\">The first method uses the popular <code class=\"markup--code markup--p-code\">BeautifulSoup<\/code> and <code class=\"markup--code markup--p-code\">Requests<\/code> libraries. These tools make it easy to analyze HTML and navigate web page structure. Below is a sample Python code.<\/p>\n<pre class=\"graf graf--pre graf--preV2\" spellcheck=\"false\" data-code-block-mode=\"1\" data-code-block-lang=\"python\"><span class=\"pre--content\"><span class=\"hljs-keyword\">import<\/span> requests\n<span class=\"hljs-keyword\">from<\/span> bs4 <span class=\"hljs-keyword\">import<\/span> BeautifulSoup\n<span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\n\n<span class=\"hljs-comment\"># Step 1: Send a GET request to the specified URL<\/span>\nresponse = requests.get(url)\n\n<span class=\"hljs-comment\"># Step 2: Parse the HTML content of the response using BeautifulSoup<\/span>\nsoup = BeautifulSoup(response.text, <span class=\"hljs-string\">'html.parser'<\/span>)\n\n<span class=\"hljs-comment\"># Step 3: Save the HTML content to a text file for reference<\/span>\n<span class=\"hljs-keyword\">with<\/span> <span class=\"hljs-built_in\">open<\/span>(<span class=\"hljs-string\">\"imdb.txt\"<\/span>, <span class=\"hljs-string\">\"w\"<\/span>, encoding=<span class=\"hljs-string\">\"utf-8\"<\/span>) <span class=\"hljs-keyword\">as<\/span> file:\n    file.write(<span class=\"hljs-built_in\">str<\/span>(soup))\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">\"Page content has been saved to imdb.txt\"<\/span>)\n\n<span class=\"hljs-comment\"># Step 4: Extract movie data from the parsed HTML and store it in a list<\/span>\nmovies_data = []\n<span class=\"hljs-keyword\">for<\/span> movie <span class=\"hljs-keyword\">in<\/span> soup.find_all(<span class=\"hljs-string\">'div'<\/span>, class_=<span class=\"hljs-string\">'lister-item-content'<\/span>):\n    title = movie.find(<span class=\"hljs-string\">'a'<\/span>).text\n    genre = movie.find(<span class=\"hljs-string\">'span'<\/span>, class_=<span class=\"hljs-string\">'genre'<\/span>).text.strip()\n    stars = movie.find(<span class=\"hljs-string\">'div'<\/span>, class_=<span class=\"hljs-string\">'ipl-rating-star'<\/span>).find(<span class=\"hljs-string\">'span'<\/span>, class_=<span class=\"hljs-string\">'ipl-rating-star__rating'<\/span>).text\n    runtime = movie.find(<span class=\"hljs-string\">'span'<\/span>, class_=<span class=\"hljs-string\">'runtime'<\/span>).text\n    rating = movie.find(<span class=\"hljs-string\">'span'<\/span>, class_=<span class=\"hljs-string\">'ipl-rating-star__rating'<\/span>).text\n    movies_data.append([title, genre, stars, runtime, rating])\n\n<span class=\"hljs-comment\"># Step 5: Create a Pandas DataFrame from the extracted movie data<\/span>\ndf = pd.DataFrame(movies_data, columns=[<span class=\"hljs-string\">'Title'<\/span>, <span class=\"hljs-string\">'Genre'<\/span>, <span class=\"hljs-string\">'Stars'<\/span>, <span class=\"hljs-string\">'Runtime'<\/span>, <span class=\"hljs-string\">'Rating'<\/span>])\n\n<span class=\"hljs-comment\"># Display the resulting DataFrame<\/span>\ndf<\/span><\/pre>\n<p class=\"graf graf--p\">In each web scraping method, I save the HTML in an <code class=\"markup--code markup--p-code\">imdb.txt<\/code> file for a clearer view of the targeted HTML elements.<\/p>\n<figure class=\"graf graf--figure\">\n<\/figure><\/div><\/div><\/section>\n\n\n\n<figure class=\"wp-block-image aligncenter graf-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*yxWPLhINzdDgJJf0P4BYbQ.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Save HTML content in a txt file (Image by the author)<\/figcaption><\/figure>\n\n\n\n<p class=\"graf graf--p\">Final Output:<\/p>\n\n\n\n<figure class=\"graf graf--figure\">\n<\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter graf-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*vHlMkgP8S2k9-8BwFr37zA.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Web scraping using BeautifulSoup and Requests (Image by the\u00a0author)<\/figcaption><\/figure>\n\n\n\n<figcaption class=\"imageCaption\">Web Scraping using BeautifulSoup and Requests (Image by the&nbsp;Author)<\/figcaption>\n\n\n\n<h3 class=\"wp-block-heading graf graf--h3\">Method 2: ScraPy for Web Scraping<\/h3>\n\n\n\n<p class=\"graf graf--p\">ScraPy is a powerful and flexible web scraping framework. Below is a code snippet showing how to use <strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">ScraPy<\/em><\/strong>, with explanations in the comments.:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-comment\"># Import necessary libraries<\/span>\n<span class=\"hljs-keyword\">import<\/span> scrapy\n<span class=\"hljs-keyword\">from<\/span> scrapy.crawler <span class=\"hljs-keyword\">import<\/span> CrawlerProcess\n\n<span class=\"hljs-comment\"># Define the Spider class for IMDb data extraction<\/span>\n<span class=\"hljs-keyword\">class<\/span> <span class=\"hljs-title class_\">IMDbSpider<\/span>(scrapy.Spider):\n    <span class=\"hljs-comment\"># Name of the spider<\/span>\n    name = <span class=\"hljs-string\">\"imdb_spider\"<\/span>\n    <span class=\"hljs-comment\"># Starting URL(s) for the spider to crawl<\/span>\n    start_urls = [<span class=\"hljs-string\">\"https:\/\/www.imdb.com\/list\/ls566941243\/\"<\/span>]\n    <span class=\"hljs-comment\"># start_urls = [url]<\/span>\n\n    <span class=\"hljs-comment\"># Parse method to extract data from the webpage<\/span>\n    <span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title function_\">parse<\/span>(<span class=\"hljs-params\">self, response<\/span>):\n        <span class=\"hljs-comment\"># Iterate over each movie item on the webpage<\/span>\n        <span class=\"hljs-keyword\">for<\/span> movie <span class=\"hljs-keyword\">in<\/span> response.css(<span class=\"hljs-string\">'div.lister-item-content'<\/span>):\n            <span class=\"hljs-keyword\">yield<\/span> {\n                <span class=\"hljs-string\">'title'<\/span>: movie.css(<span class=\"hljs-string\">'h3.lister-item-header a::text'<\/span>).get(),\n                <span class=\"hljs-string\">'genre'<\/span>: movie.css(<span class=\"hljs-string\">'p.text-muted span.genre::text'<\/span>).get(),\n                <span class=\"hljs-string\">'runtime'<\/span>: movie.css(<span class=\"hljs-string\">'p.text-muted span.runtime::text'<\/span>).get(),\n                <span class=\"hljs-string\">'rating'<\/span>: movie.css(<span class=\"hljs-string\">'div.ipl-rating-star span.ipl-rating-star__rating::text'<\/span>).get(),\n            }\n<span class=\"hljs-comment\"># Initialize a CrawlerProcess instance with settings<\/span>\nprocess = CrawlerProcess(settings={\n    <span class=\"hljs-string\">'FEED_FORMAT'<\/span>: <span class=\"hljs-string\">'json'<\/span>,\n    <span class=\"hljs-string\">'FEED_URI'<\/span>: <span class=\"hljs-string\">'output.json'<\/span>,  <span class=\"hljs-comment\"># This will overwrite the file every time you run the spider<\/span>\n})\n\n\n<span class=\"hljs-comment\"># Add the IMDbSpider to the crawling process<\/span>\nprocess.crawl(IMDbSpider)\n<span class=\"hljs-comment\"># Start the crawling process<\/span>\nprocess.start()<\/span><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\n\n<span class=\"hljs-comment\"># Read the output.json file into a DataFrame (jsonlines format)<\/span>\ndf = pd.read_json(<span class=\"hljs-string\">'output.json'<\/span>)\n\n<span class=\"hljs-comment\"># Display the DataFrame<\/span>\ndf.head()<\/span><\/pre>\n\n\n\n<p class=\"graf graf--p\">In this demo, I\u2019m using Jupyter Notebook. If you encounter a <strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">ReactorNotRestartable<\/em><\/strong> error, just restart the kernel and run the code again.<\/p>\n\n\n\n<figure class=\"graf graf--figure\">\n<\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter graf-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*0ostaXEaX6_i2XpwfUToJQ.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Example: ReactorNotRestartable Error while using\u00a0ScraPy<\/figcaption><\/figure>\n\n\n\n<figcaption class=\"imageCaption\"><\/figcaption>\n\n\n\n<p class=\"graf graf--p\">Display the data in a dataframe:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\n\n<span class=\"hljs-comment\"># Read the output.json file into a DataFrame (jsonlines format)<\/span>\ndf = pd.read_json(<span class=\"hljs-string\">'output.json'<\/span>)\n\n<span class=\"hljs-comment\"># Display the DataFrame<\/span>\ndf.head()<\/span><\/pre>\n\n\n\n<h3 class=\"wp-block-heading graf graf--h3\">Method 3: Selenium for Web Scraping<\/h3>\n\n\n\n<p class=\"graf graf--p\">Selenium is often used for dynamic web scraping. Here\u2019s a basic example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-keyword\">from<\/span> selenium <span class=\"hljs-keyword\">import<\/span> webdriver\n<span class=\"hljs-keyword\">from<\/span> bs4 <span class=\"hljs-keyword\">import<\/span> BeautifulSoup\n<span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\n\n<span class=\"hljs-comment\"># URL of the IMDb list<\/span>\nurl = <span class=\"hljs-string\">\"https:\/\/www.imdb.com\/list\/ls566941243\/\"<\/span>\n\n<span class=\"hljs-comment\"># Set up Chrome options to run the browser in incognito mode<\/span>\nchrome_options = webdriver.ChromeOptions()\nchrome_options.add_argument(<span class=\"hljs-string\">\"--incognito\"<\/span>)\n\n<span class=\"hljs-comment\"># Initialize the Chrome driver with the specified options<\/span>\ndriver = webdriver.Chrome(options=chrome_options)\n\n<span class=\"hljs-comment\"># Navigate to the IMDb list URL<\/span>\ndriver.get(url)\n\n<span class=\"hljs-comment\"># Wait for the page to load (adjust the wait time according to your webpage)<\/span>\ndriver.implicitly_wait(<span class=\"hljs-number\">10<\/span>)\n\n<span class=\"hljs-comment\"># Get the HTML content of the page after it has fully loaded<\/span>\nhtml_content = driver.page_source\n\n<span class=\"hljs-comment\"># Parse the HTML content with BeautifulSoup<\/span>\nsoup = BeautifulSoup(html_content, <span class=\"hljs-string\">'html.parser'<\/span>)\n\n<span class=\"hljs-comment\"># Save the HTML content to a text file for reference<\/span>\n<span class=\"hljs-keyword\">with<\/span> <span class=\"hljs-built_in\">open<\/span>(<span class=\"hljs-string\">\"imdb_selenium.txt\"<\/span>, <span class=\"hljs-string\">\"w\"<\/span>, encoding=<span class=\"hljs-string\">\"utf-8\"<\/span>) <span class=\"hljs-keyword\">as<\/span> file:\n    file.write(<span class=\"hljs-built_in\">str<\/span>(soup))\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">\"Page content has been saved to imdb_selenium.txt\"<\/span>)\n\n<span class=\"hljs-comment\"># Extract movie data from the parsed HTML<\/span>\nmovies_data = []\n<span class=\"hljs-keyword\">for<\/span> movie <span class=\"hljs-keyword\">in<\/span> soup.find_all(<span class=\"hljs-string\">'div'<\/span>, class_=<span class=\"hljs-string\">'lister-item-content'<\/span>):\n    title = movie.find(<span class=\"hljs-string\">'a'<\/span>).text\n    genre = movie.find(<span class=\"hljs-string\">'span'<\/span>, class_=<span class=\"hljs-string\">'genre'<\/span>).text.strip()\n    stars = movie.select_one(<span class=\"hljs-string\">'div.ipl-rating-star span.ipl-rating-star__rating'<\/span>).text\n    runtime = movie.find(<span class=\"hljs-string\">'span'<\/span>, class_=<span class=\"hljs-string\">'runtime'<\/span>).text\n    rating = movie.select_one(<span class=\"hljs-string\">'div.ipl-rating-star span.ipl-rating-star__rating'<\/span>).text\n    movies_data.append([title, genre, stars, runtime, rating])\n\n<span class=\"hljs-comment\"># Create a Pandas DataFrame from the collected movie data<\/span>\ndf = pd.DataFrame(movies_data, columns=[<span class=\"hljs-string\">'Title'<\/span>, <span class=\"hljs-string\">'Genre'<\/span>, <span class=\"hljs-string\">'Stars'<\/span>, <span class=\"hljs-string\">'Runtime'<\/span>, <span class=\"hljs-string\">'Rating'<\/span>])\n\n<span class=\"hljs-comment\"># Display the resulting DataFrame<\/span>\n<span class=\"hljs-built_in\">print<\/span>(df)\n\n<span class=\"hljs-comment\"># Close the Chrome driver<\/span>\ndriver.quit()<\/span><\/pre>\n\n\n\n<p class=\"graf graf--p\">Final Output:<\/p>\n\n\n\n<figure class=\"graf graf--figure\">\n<\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter graf-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*2K4HxrQJBgAcyS6Jc9M44A.png\" alt=\"\"\/><figcaption class=\"wp-element-caption\">Web Scraping using selenium (Image by the\u00a0Author)<\/figcaption><\/figure>\n\n\n\n<figcaption class=\"imageCaption\"><\/figcaption>\n\n\n\n<p class=\"graf graf--p\">The key to <strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">Selenium<\/em><\/strong> is in its <strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">Chrome options<\/em><\/strong>, which are settings for customizing the behavior of the Chrome browser controlled by Selenium WebDriver. These options enable control over aspects like incognito mode, window size, notifications, and more.<\/p>\n\n\n\n<p class=\"graf graf--p\">Here are some important Chrome options that you might find useful:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-comment\"># Runs the browser in incognito (private browsing) mode.<\/span>\nchrome_options.add_argument(<span class=\"hljs-string\">\"--incognito\"<\/span>)\n\n<span class=\"hljs-comment\"># Runs the browser in headless mode, i.e., without a graphical user interface. <\/span>\n<span class=\"hljs-comment\"># Useful for running Selenium tests in the background without opening a visible browser window.<\/span>\nchrome_options.add_argument(<span class=\"hljs-string\">\"--headless\"<\/span>)\n\n<span class=\"hljs-comment\"># Sets the initial window size of the browser.<\/span>\nchrome_options.add_argument(<span class=\"hljs-string\">\"--window-size=1200x600\"<\/span>)\n\n<span class=\"hljs-comment\"># Disables browser notifications.<\/span>\nchrome_options.add_argument(<span class=\"hljs-string\">\"--disable-notifications\"<\/span>)\n\n<span class=\"hljs-comment\"># Disables the infobar that appears at the top of the browser.<\/span>\nchrome_options.add_argument(<span class=\"hljs-string\">\"--disable-infobars\"<\/span>)\n\n<span class=\"hljs-comment\"># Disables browser extensions.<\/span>\nchrome_options.add_argument(<span class=\"hljs-string\">\"--disable-extensions\"<\/span>)\n\n<span class=\"hljs-comment\"># Disables the GPU hardware acceleration.<\/span>\nchrome_options.add_argument(<span class=\"hljs-string\">\"--disable-gpu\"<\/span>)\n\n<span class=\"hljs-comment\"># Disables web security features, which can be useful for testing on localhost without CORS issues.<\/span>\nchrome_options.add_argument(<span class=\"hljs-string\">\"--disable-web-security\"<\/span>)<\/span><\/pre>\n\n\n\n<p class=\"graf graf--p\">These options can be combined or used individually based on your requirements. When you create a <code class=\"markup--code markup--p-code\">webdriver.Chrome<\/code> instance, you can pass these options using the <code class=\"markup--code markup--p-code\">options<\/code> parameter:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-keyword\">from<\/span> selenium <span class=\"hljs-keyword\">import<\/span> webdriver\n\nchrome_options = webdriver.ChromeOptions()\nchrome_options.add_argument(<span class=\"hljs-string\">\"--incognito\"<\/span>)\nchrome_options.add_argument(<span class=\"hljs-string\">\"--headless\"<\/span>)\n\ndriver = webdriver.Chrome(options=chrome_options)<\/span><\/pre>\n\n\n\n<p class=\"graf graf--p\">These options provide flexibility and control over the browser\u2019s behavior when using Selenium for web automation or testing. Choose options based on your specific use case and requirements.<\/p>\n\n\n\n<h3 class=\"wp-block-heading graf graf--h3\">Method 4: <strong class=\"markup--strong markup--h3-strong\">Requests and lxml for Web Scraping<\/strong><\/h3>\n\n\n\n<p class=\"graf graf--p\"><strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">lxml<\/em><\/strong> is a Python library linking with C libraries <strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">libxml2<\/em><\/strong> and <strong class=\"markup--strong markup--p-strong\"><em class=\"markup--em markup--p-em\">libxslt<\/em><\/strong>, combining speed and XML features with a simple native Python API, similar to ElementTree but with added benefits.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-keyword\">import<\/span> requests\n<span class=\"hljs-keyword\">from<\/span> lxml <span class=\"hljs-keyword\">import<\/span> html\n<span class=\"hljs-keyword\">import<\/span> pandas <span class=\"hljs-keyword\">as<\/span> pd\n\n<span class=\"hljs-comment\"># Define the URL<\/span>\nurl = <span class=\"hljs-string\">\"https:\/\/www.imdb.com\/list\/ls566941243\/\"<\/span>\n\n<span class=\"hljs-comment\"># Send an HTTP request to the URL and get the response<\/span>\nresponse = requests.get(url)\n\n<span class=\"hljs-comment\"># Parse the HTML content using lxml<\/span>\ntree = html.fromstring(response.content)\n\n<span class=\"hljs-comment\"># Extract movie data from the parsed HTML<\/span>\ntitles = tree.xpath(<span class=\"hljs-string\">'\/\/h3[@class=\"lister-item-header\"]\/a\/text()'<\/span>)\ngenres = [<span class=\"hljs-string\">', '<\/span>.join(genre.strip() <span class=\"hljs-keyword\">for<\/span> genre <span class=\"hljs-keyword\">in<\/span> genre_list.xpath(<span class=\"hljs-string\">\".\/\/text()\"<\/span>)) <span class=\"hljs-keyword\">for<\/span> genre_list <span class=\"hljs-keyword\">in<\/span> tree.xpath(<span class=\"hljs-string\">'\/\/p[@class=\"text-muted text-small\"]\/span[@class=\"genre\"]'<\/span>)]\nratings = tree.xpath(<span class=\"hljs-string\">'\/\/div[@class=\"ipl-rating-star small\"]\/span[@class=\"ipl-rating-star__rating\"]\/text()'<\/span>)\nruntimes = tree.xpath(<span class=\"hljs-string\">'\/\/p[@class=\"text-muted text-small\"]\/span[@class=\"runtime\"]\/text()'<\/span>)\n\n<span class=\"hljs-comment\"># Create a dictionary with extracted data<\/span>\ndata = {\n    <span class=\"hljs-string\">'Title'<\/span>: titles,\n    <span class=\"hljs-string\">'Genre'<\/span>: genres,\n    <span class=\"hljs-string\">'Rating'<\/span>: ratings,\n    <span class=\"hljs-string\">'Runtime'<\/span>: runtimes\n}\n\n<span class=\"hljs-comment\"># Create a DataFrame from the dictionary<\/span>\ndf = pd.DataFrame(data)\n\n<span class=\"hljs-comment\"># Display the resulting DataFrame<\/span>\ndf.head()<\/span><\/pre>\n\n\n\n<h3 class=\"wp-block-heading graf graf--h3\">Method 5: How to Use LangChain for Web&nbsp;Scraping<\/h3>\n\n\n\n<p class=\"graf graf--p\">I bet all the readers who are interested this article know about ChatGPT, BARD. LLM makes life simpler. You can use it for various tasks, like asking <em class=\"markup--em markup--p-em\">\u2018Who is Donald Trump?\u2019 or \u2018Translate sentences from German to English,\u2019<\/em> and get quick answers. The good news is you can also use them for Web Scraping. Here\u2019s how.<\/p>\n\n\n\n<p class=\"graf graf--p\"><em class=\"markup--em markup--p-em\">\ud83d\udc49 Helpful LangChain resources for this demo:<\/em><\/p>\n\n\n\n<ul class=\"wp-block-list postList\">\n<li><a class=\"markup--anchor markup--li-anchor\" data-href=\"https:\/\/python.langchain.com\/docs\/integrations\/document_transformers\/beautiful_soup\" href=\"https:\/\/python.langchain.com\/docs\/integrations\/document_transformers\/beautiful_soup\" target=\"_blank\" rel=\"noopener\"><em class=\"markup--em markup--li-em\">LangChain Beautiful Soup<\/em><\/a><\/li>\n\n\n\n<li><a class=\"markup--anchor markup--li-anchor\" data-href=\"https:\/\/python.langchain.com\/docs\/use_cases\/extraction\" href=\"https:\/\/python.langchain.com\/docs\/use_cases\/extraction\" target=\"_blank\" rel=\"noopener\"><em class=\"markup--em markup--li-em\">LangChain Extraction<\/em><\/a><\/li>\n<\/ul>\n\n\n\n<p>&nbsp;<\/p>\n\n\n\n<figure class=\"graf graf--figure\">\n<\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter graf-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*Seui-YR43HJ8e3J7nvzFAA.png\" alt=\"A diagram illustrating the web scraping workflow using LLMs\"\/><figcaption class=\"wp-element-caption\">Web Scraping using LangChain LLM (Image by the\u00a0Author)<\/figcaption><\/figure>\n\n\n\n<figcaption class=\"imageCaption\"><\/figcaption>\n\n\n\n<p class=\"graf graf--p\">Brief explanations for each code line are provided in the comments.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-keyword\">import<\/span> os\n<span class=\"hljs-keyword\">import<\/span> dotenv\n<span class=\"hljs-keyword\">import<\/span> time\n\n<span class=\"hljs-comment\"># Load environment variables from a .env file<\/span>\ndotenv.load_dotenv()\n\n<span class=\"hljs-comment\"># Retrieve OpenAI and Comet key from environment variables<\/span>\nMY_OPENAI_KEY = os.getenv(<span class=\"hljs-string\">\"MY_OPENAI_KEY\"<\/span>)\nMY_COMET_KEY = os.getenv(<span class=\"hljs-string\">\"MY_COMET_KEY\"<\/span>)<\/span><\/pre>\n\n\n\n<p class=\"graf graf--p\">In my LLM Project, I usually record outputs in a Comet Project. In this demo, I\u2019m using just 01 URL. However, if you need to loop through multiple URLs, Comet LLM\u2019s experiment tracking is very useful.<\/p>\n\n\n\n<p class=\"graf graf--p\"><em class=\"markup--em markup--p-em\">\ud83d\udc49 Read more about <\/em><a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/www.comet.com\/site\/products\/llmops\/\" target=\"_blank\" rel=\"noopener\" data-href=\"https:\/\/www.comet.com\/site\/products\/llmops\/\"><em class=\"markup--em markup--p-em\">Comet LLM<\/em><\/a><em class=\"markup--em markup--p-em\">.<\/em><\/p>\n\n\n\n<p class=\"graf graf--p\"><em class=\"markup--em markup--p-em\">\ud83d\udc49 How to obtain the API keys: <\/em><a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/help.openai.com\/en\/articles\/4936850-where-do-i-find-my-api-key\" target=\"_blank\" rel=\"noopener ugc nofollow\" data-href=\"https:\/\/help.openai.com\/en\/articles\/4936850-where-do-i-find-my-api-key\"><em class=\"markup--em markup--p-em\">OpenAI Help Center\u200a\u2014\u200aWhere can I find my API key?<\/em><\/a><em class=\"markup--em markup--p-em\">; <\/em><a class=\"markup--anchor markup--p-anchor\" href=\"https:\/\/www.comet.com\/docs\/v2\/api-and-sdk\/rest-api\/overview\/\" target=\"_blank\" rel=\"noopener ugc nofollow\" data-href=\"https:\/\/www.comet.com\/docs\/v2\/api-and-sdk\/rest-api\/overview\/\"><em class=\"markup--em markup--p-em\">CometLLM\u200a\u2014\u200aObtaining your API key<\/em><\/a><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-keyword\">import<\/span> comet_llm\n\n<span class=\"hljs-comment\"># Initialize a Comet project<\/span>\ncomet_llm.init(project=<span class=\"hljs-string\">\"langchain-web-scraping\"<\/span>,\n               api_key=MY_COMET_KEY,\n               )<\/span><\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-comment\"># Resolve async issues by applying nest_asyncio<\/span>\n<span class=\"hljs-keyword\">import<\/span> nest_asyncio\nnest_asyncio.apply()\n\n<span class=\"hljs-comment\"># Import required modules from langchain<\/span>\n<span class=\"hljs-keyword\">from<\/span> langchain_openai <span class=\"hljs-keyword\">import<\/span> ChatOpenAI\n<span class=\"hljs-keyword\">from<\/span> langchain_community.document_loaders <span class=\"hljs-keyword\">import<\/span> AsyncChromiumLoader\n<span class=\"hljs-keyword\">from<\/span> langchain_community.document_transformers <span class=\"hljs-keyword\">import<\/span> BeautifulSoupTransformer\n<span class=\"hljs-keyword\">from<\/span> langchain.text_splitter <span class=\"hljs-keyword\">import<\/span> RecursiveCharacterTextSplitter\n<span class=\"hljs-keyword\">from<\/span> langchain.chains <span class=\"hljs-keyword\">import<\/span> create_extraction_chain\n\n<span class=\"hljs-comment\"># Define the URL<\/span>\nurl = <span class=\"hljs-string\">\"https:\/\/www.imdb.com\/list\/ls566941243\/\"<\/span>\n\n<span class=\"hljs-comment\"># Initialize ChatOpenAI instance with OpenAI API key<\/span>\nllm = ChatOpenAI(openai_api_key=MY_OPENAI_KEY)\n\n<span class=\"hljs-comment\"># Load HTML content using AsyncChromiumLoader<\/span>\nloader = AsyncChromiumLoader([url])\ndocs = loader.load()\n\n<span class=\"hljs-comment\"># Save the HTML content to a text file for reference<\/span>\n<span class=\"hljs-keyword\">with<\/span> <span class=\"hljs-built_in\">open<\/span>(<span class=\"hljs-string\">\"imdb_langchain_html.txt\"<\/span>, <span class=\"hljs-string\">\"w\"<\/span>, encoding=<span class=\"hljs-string\">\"utf-8\"<\/span>) <span class=\"hljs-keyword\">as<\/span> file:\n    file.write(<span class=\"hljs-built_in\">str<\/span>(docs[<span class=\"hljs-number\">0<\/span>].page_content))\n<span class=\"hljs-built_in\">print<\/span>(<span class=\"hljs-string\">\"Page content has been saved to imdb_langchain_html.txt\"<\/span>)\n\n<span class=\"hljs-comment\"># Transform the loaded HTML using BeautifulSoupTransformer<\/span>\nbs_transformer = BeautifulSoupTransformer()\ndocs_transformed = bs_transformer.transform_documents(\n    docs, tags_to_extract=[<span class=\"hljs-string\">\"h3\"<\/span>, <span class=\"hljs-string\">\"p\"<\/span>]\n)\n\n<span class=\"hljs-comment\"># Split the transformed documents using RecursiveCharacterTextSplitter<\/span>\nsplitter = RecursiveCharacterTextSplitter.from_tiktoken_encoder(chunk_size=<span class=\"hljs-number\">1000<\/span>, chunk_overlap=<span class=\"hljs-number\">0<\/span>)\nsplits = splitter.split_documents(docs_transformed)<\/span><\/pre>\n\n\n\n<p class=\"graf graf--p\">Please note that depending on your needs, you might want to explore the HTML layout to select the right <code class=\"markup--code markup--p-code\">tags_to_extract<\/code>. In this demo, I am extracting <code class=\"markup--code markup--p-code\">movie title, genre, rating, and runtime<\/code>, so I\u2019ll go with the <code class=\"markup--code markup--p-code\">&lt;h3&gt;<\/code> and <code class=\"markup--code markup--p-code\">&lt;p&gt;<\/code> tags.<\/p>\n\n\n\n<figure class=\"wp-block-image aligncenter graf graf--figure\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*W3x49FEVsPtabyHMIYhmEg.png\" alt=\"\"\/><\/figure>\n\n\n\n<p class=\"graf graf--p\">Basically after obtaining the required HTML, we will ask LLM: <em class=\"markup--em markup--p-em\">\u201cHey LLM, with this HTML, please fill in the information according to the schema below.\u201d<\/em><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-comment\"># Define a JSON schema for movie data validation<\/span>\nschema = {\n    <span class=\"hljs-string\">\"properties\"<\/span>: {\n        <span class=\"hljs-string\">\"movie_title\"<\/span>: {<span class=\"hljs-string\">\"type\"<\/span>: <span class=\"hljs-string\">\"string\"<\/span>},\n        <span class=\"hljs-string\">\"stars\"<\/span>: {<span class=\"hljs-string\">\"type\"<\/span>: <span class=\"hljs-string\">\"integer\"<\/span>},\n        <span class=\"hljs-string\">\"genre\"<\/span>: {<span class=\"hljs-string\">\"type\"<\/span>: <span class=\"hljs-string\">\"array\"<\/span>, <span class=\"hljs-string\">\"items\"<\/span>: {<span class=\"hljs-string\">\"type\"<\/span>: <span class=\"hljs-string\">\"string\"<\/span>}},\n        <span class=\"hljs-string\">\"runtime\"<\/span>: {<span class=\"hljs-string\">\"type\"<\/span>: <span class=\"hljs-string\">\"string\"<\/span>},\n        <span class=\"hljs-string\">\"rating\"<\/span>: {<span class=\"hljs-string\">\"type\"<\/span>: <span class=\"hljs-string\">\"string\"<\/span>},\n    },\n    <span class=\"hljs-string\">\"required\"<\/span>: [<span class=\"hljs-string\">\"movie_title\"<\/span>, <span class=\"hljs-string\">\"stars\"<\/span>, <span class=\"hljs-string\">\"genre\"<\/span>, <span class=\"hljs-string\">\"runtime\"<\/span>, <span class=\"hljs-string\">\"rating\"<\/span>],\n}\n\n<span class=\"hljs-keyword\">def<\/span> <span class=\"hljs-title function_\">extract_movie_data<\/span>(<span class=\"hljs-params\">content: <span class=\"hljs-built_in\">str<\/span>, schema: <span class=\"hljs-built_in\">dict<\/span><\/span>):\n    <span class=\"hljs-string\">\"\"\"\n    Extract movie data from content using a specified JSON schema.\n\n    Parameters:\n    - content (str): Text content containing movie data.\n    - schema (dict): JSON schema for validating the movie data.\n\n    Returns:\n    - dict: Extracted movie data.\n    \"\"\"<\/span>\n    <span class=\"hljs-comment\"># Run the extraction chain with the provided schema and content<\/span>\n    start_time = time.time()\n    extracted_content = create_extraction_chain(schema=schema, llm=llm).run(content)\n    end_time = time.time()\n\n    <span class=\"hljs-comment\"># Log metadata and output in the Comet project for tracking purposes<\/span>\n    comet_llm.log_prompt(\n        prompt=<span class=\"hljs-built_in\">str<\/span>(content),\n        metadata= {\n            <span class=\"hljs-string\">\"schema\"<\/span>: schema\n        },\n        output= extracted_content,\n        duration= end_time - start_time,\n    )\n\n    <span class=\"hljs-keyword\">return<\/span> extracted_content\n\n<\/span><\/pre>\n\n\n\n<p class=\"graf graf--p\">And finally, we\u2019ve got the result:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"><span class=\"pre--content\"><span class=\"hljs-comment\"># Extract movie data using the defined schema and the first split page content<\/span>\nextracted_content <span class=\"hljs-punctuation\">=<\/span> extract_movie_data<span class=\"hljs-punctuation\">(<\/span><span class=\"hljs-keyword\">schema<\/span><span class=\"hljs-punctuation\">=<\/span><span class=\"hljs-keyword\">schema<\/span>, content<span class=\"hljs-punctuation\">=<\/span>splits<span class=\"hljs-punctuation\">[<\/span><span class=\"hljs-number\">0<\/span><span class=\"hljs-punctuation\">]<\/span>.page_content<span class=\"hljs-punctuation\">)<\/span>\n\n<span class=\"hljs-comment\"># Display the extracted movie data<\/span>\nextracted_content<\/span><\/pre>\n\n\n\n<p class=\"graf graf--p\">Final Output:<\/p>\n\n\n\n<figure class=\"graf graf--figure\">\n<\/figure>\n\n\n\n<figure class=\"wp-block-image aligncenter graf-image\"><img decoding=\"async\" src=\"https:\/\/cdn-images-1.medium.com\/max\/1600\/1*YMqSmcNzlRlYWFkANnbspg.png\" alt=\"A screenshot of the output of using LangChain LLM for web scraping\"\/><figcaption class=\"wp-element-caption\">Output: Web scraping using LangChain LLM (Image by the\u00a0author)<\/figcaption><\/figure>\n\n\n\n<figcaption class=\"imageCaption\"><\/figcaption>\n\n\n\n<p class=\"graf graf--p\">There\u2019s a lot to discover about LLMs. Want more topics on LLM? Share your thoughts in the comments!<\/p>\n\n\n\n<div class=\"graf graf--mixtapeEmbed\"><a class=\"markup--anchor markup--mixtapeEmbed-anchor\" title=\"https:\/\/heartbeat.comet.ml\/how-to-create-a-simple-chatbot-for-e-commerce-using-openai-aa0539b9875b\" href=\"https:\/\/heartbeat.comet.ml\/how-to-create-a-simple-chatbot-for-e-commerce-using-openai-aa0539b9875b\" data-href=\"https:\/\/heartbeat.comet.ml\/how-to-create-a-simple-chatbot-for-e-commerce-using-openai-aa0539b9875b\"><strong class=\"markup--strong markup--mixtapeEmbed-strong\">How to Create a Simple Chatbot for E-commerce Using OpenAI<\/strong><br>\n<em class=\"markup--em markup--mixtapeEmbed-em\">Forget about complicated Deep Learning algorithms\u200a\u2014\u200amaking a chatbot is way simpler with OpenAI.<\/em>heartbeat.comet.ml<\/a><\/div>\n\n\n\n<div class=\"graf graf--mixtapeEmbed\"><a class=\"markup--anchor markup--mixtapeEmbed-anchor\" title=\"https:\/\/heartbeat.comet.ml\/how-to-enhance-conversational-agents-with-memory-in-lang-chain-6aadd335b621\" href=\"https:\/\/heartbeat.comet.ml\/how-to-enhance-conversational-agents-with-memory-in-lang-chain-6aadd335b621\" data-href=\"https:\/\/heartbeat.comet.ml\/how-to-enhance-conversational-agents-with-memory-in-lang-chain-6aadd335b621\"><strong class=\"markup--strong markup--mixtapeEmbed-strong\">How to Enhance Conversational Agents with Memory in Lang Chain<\/strong><br>\n<em class=\"markup--em markup--mixtapeEmbed-em\">LangChain Conversation Memory Types: Pros &amp; Cons, and Code Examples<\/em>heartbeat.comet.ml<\/a><\/div>\n\n\n\n<h3 class=\"wp-block-heading graf graf--h3\"><em class=\"markup--em markup--h3-em\">\u2757<\/em>A Heads-up<\/h3>\n\n\n\n<p class=\"graf graf--p\">Web scraping is not as simple as you might think. You may face challenges along the way.<\/p>\n\n\n\n<ol class=\"wp-block-list postList\">\n<li><strong class=\"markup--strong markup--li-strong\">Dynamic website structures:<\/strong> Modern websites use dynamic JavaScript structures and require tools like Selenium for accurate data extraction.<\/li>\n\n\n\n<li><strong class=\"markup--strong markup--li-strong\">Anti-scraping<\/strong>: IP blocks and CAPTCHAs are common deterrents. Strategies such as IP address rotation can help overcome these obstacles.<\/li>\n\n\n\n<li><strong class=\"markup--strong markup--li-strong\">Legal and Ethical Considerations<\/strong>: To avoid legal repercussions, it is important to follow the website\u2019s terms of use. Prioritize ethical practices and ask for permission.<\/li>\n\n\n\n<li><strong class=\"markup--strong markup--li-strong\">Data quality and consistency<\/strong>: Maintaining data quality while updating a website is an ongoing challenge. Update your scraping script regularly to ensure accurate and reliable extraction.<\/li>\n<\/ol>\n\n\n\n<h3 class=\"wp-block-heading graf graf--h3\">Conclusion<\/h3>\n\n\n\n<p class=\"graf graf--p\">Web scraping is worth a try. It may not seem like a formal job, but it\u2019s actually a lot of fun using Python, JavaScript, and HTML. There are many ways to collect information from websites. I hope you will try more than just web scraping by implementing LLM techniques.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Introduction Web scraping automates the extraction of data from websites using programming or specialized tools. Required for tasks such as market research, data analysis, content aggregation, and competitive intelligence. This efficient method saves time, improves decision making, and allows businesses to study trends and patterns, making it a powerful tool for extracting valuable information from [&hellip;]<\/p>\n","protected":false},"author":95,"featured_media":9390,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"customer_name":"","customer_description":"","customer_industry":"","customer_technologies":"","customer_logo":"","footnotes":""},"categories":[65,7],"tags":[40,64,70,71,52,31,80],"coauthors":[192],"class_list":["post-9379","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-llmops","category-tutorials","tag-comet","tag-cometllm","tag-langchain","tag-language-models","tag-llm","tag-llmops","tag-web-scraping"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v25.9) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Top 5 Web Scraping Methods: Including Using LLMs - Comet<\/title>\n<meta name=\"description\" content=\"Web scraping automates the extraction of data from websites using programming or specialized tools and now it can be done using LLMs!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Top 5 Web Scraping Methods: Including Using LLMs\" \/>\n<meta property=\"og:description\" content=\"Web scraping automates the extraction of data from websites using programming or specialized tools and now it can be done using LLMs!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/\" \/>\n<meta property=\"og:site_name\" content=\"Comet\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/cometdotml\" \/>\n<meta property=\"article:published_time\" content=\"2024-02-27T01:07:30+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-04-24T17:03:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash-1024x683.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1024\" \/>\n\t<meta property=\"og:image:height\" content=\"683\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Nhi Yen\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@Cometml\" \/>\n<meta name=\"twitter:site\" content=\"@Cometml\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Nhi Yen\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"14 minutes\" \/>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Top 5 Web Scraping Methods: Including Using LLMs - Comet","description":"Web scraping automates the extraction of data from websites using programming or specialized tools and now it can be done using LLMs!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/","og_locale":"en_US","og_type":"article","og_title":"Top 5 Web Scraping Methods: Including Using LLMs","og_description":"Web scraping automates the extraction of data from websites using programming or specialized tools and now it can be done using LLMs!","og_url":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/","og_site_name":"Comet","article_publisher":"https:\/\/www.facebook.com\/cometdotml","article_published_time":"2024-02-27T01:07:30+00:00","article_modified_time":"2025-04-24T17:03:07+00:00","og_image":[{"width":1024,"height":683,"url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash-1024x683.jpg","type":"image\/jpeg"}],"author":"Nhi Yen","twitter_card":"summary_large_image","twitter_creator":"@Cometml","twitter_site":"@Cometml","twitter_misc":{"Written by":"Nhi Yen","Est. reading time":"14 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/#article","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/"},"author":{"name":"Nhi Yen","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/1a873c6cf609e07d582cd696f147609b"},"headline":"Top 5 Web Scraping Methods: Including Using LLMs","datePublished":"2024-02-27T01:07:30+00:00","dateModified":"2025-04-24T17:03:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/"},"wordCount":1346,"publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/#primaryimage"},"thumbnailUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash.jpg","keywords":["Comet","CometLLM","LangChain","Language Models","LLM","LLMOps","Web Scraping"],"articleSection":["LLMOps","Tutorials"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/","url":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/","name":"Top 5 Web Scraping Methods: Including Using LLMs - Comet","isPartOf":{"@id":"https:\/\/www.comet.com\/site\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/#primaryimage"},"image":{"@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/#primaryimage"},"thumbnailUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash.jpg","datePublished":"2024-02-27T01:07:30+00:00","dateModified":"2025-04-24T17:03:07+00:00","description":"Web scraping automates the extraction of data from websites using programming or specialized tools and now it can be done using LLMs!","breadcrumb":{"@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/#primaryimage","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash.jpg","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2024\/02\/nathan-dumlao-kME9jbKd-s-unsplash.jpg","width":7734,"height":5159,"caption":"spiderweb with water droplets"},{"@type":"BreadcrumbList","@id":"https:\/\/www.comet.com\/site\/blog\/top-5-web-scraping-methods-including-using-llms\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.comet.com\/site\/"},{"@type":"ListItem","position":2,"name":"Top 5 Web Scraping Methods: Including Using LLMs"}]},{"@type":"WebSite","@id":"https:\/\/www.comet.com\/site\/#website","url":"https:\/\/www.comet.com\/site\/","name":"Comet","description":"Build Better Models Faster","publisher":{"@id":"https:\/\/www.comet.com\/site\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.comet.com\/site\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.comet.com\/site\/#organization","name":"Comet ML, Inc.","alternateName":"Comet","url":"https:\/\/www.comet.com\/site\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/","url":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","contentUrl":"https:\/\/www.comet.com\/site\/wp-content\/uploads\/2025\/01\/logo_comet_square.png","width":310,"height":310,"caption":"Comet ML, Inc."},"image":{"@id":"https:\/\/www.comet.com\/site\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/cometdotml","https:\/\/x.com\/Cometml","https:\/\/www.youtube.com\/channel\/UCmN63HKvfXSCS-UwVwmK8Hw"]},{"@type":"Person","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/1a873c6cf609e07d582cd696f147609b","name":"Nhi Yen","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.comet.com\/site\/#\/schema\/person\/image\/cbe7005c33fc937d23d6bbbff99e5223","url":"https:\/\/secure.gravatar.com\/avatar\/ec9f8f996211d944f352679e89c48b4cdaf7a1609d7409846408ac93045893d9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ec9f8f996211d944f352679e89c48b4cdaf7a1609d7409846408ac93045893d9?s=96&d=mm&r=g","caption":"Nhi Yen"},"url":"https:\/\/www.comet.com\/site\/blog\/author\/nhi-yen\/"}]}},"_links":{"self":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/9379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/users\/95"}],"replies":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/comments?post=9379"}],"version-history":[{"count":1,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/9379\/revisions"}],"predecessor-version":[{"id":15382,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/posts\/9379\/revisions\/15382"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media\/9390"}],"wp:attachment":[{"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/media?parent=9379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/categories?post=9379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/tags?post=9379"},{"taxonomy":"author","embeddable":true,"href":"https:\/\/www.comet.com\/site\/wp-json\/wp\/v2\/coauthors?post=9379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}