Scraping with Python
Build your scraper from zero with ChatGPT
Last updated
Was this helpful?
Build your scraper from zero with ChatGPT
Last updated
Was this helpful?
You have many ways to do it with ChatGPT, but for this example we won't ask for a complete code since the beginning, we'll do it step by step. Let's start!
First, we'll just ask for a small piece of our scraper and in the next steps we will start to improve it also using ChatGPT. The first function we'll create will be for extract the URLs present in the first website we visit.
As we can see, we will have to install BeautifulSoup and requests:
When I ran this code with the url https://docs.gpt4devs.com I found many urls starting with "/" so I can't visit them automatically, because they're invalid. Let's say to ChatGPT that we need to fix the URL when it's starting with a "/"
We will start to extract some information of each URL. For this example I just wanted to extract the title, but you can ask for extract other tags or information