Can ChatGPT write web crawling code well?
In this post, I experimented whether the ChatGTP could write the crawling code of the ETF website that I uploaded in the existing blog post.
First of all, please refer to the following post that I coded to crawl the individual ETF information from Blackrock's website.
Mission of this post
I am going to write the chatGPT prompt for fetching the text field value(e.g. "$15,216,074,479") of the "Net Assets of Fund" under the "Key Facts" section within the individual ETF page.
Writing the Prompt
I assume that you have the basic knowledge of html document,and can analyze html elements using the tools such as Chrome Devtools. As I wrote in the previous post, you can analyze the HTML tags in which you want to extract first and make order ChatGPT for that work.
Now I have written the prompt. It would be useful to list the prompt to write the code sequentially as shown below.
ChatGPT Prompt
1) crawl https://www.ishares.com/us/products/239565/ishares-iboxx-high-yield-corporate-bond-etf
2) extract text from span tag(wrapped by div tag whose class name contains "float-left in-left col-totalNetAssetsFundLevel") whose class name is "data"
3) convert text from currency type to number
4) return the number
The code written by ChatGPT is as follows.
When I ran the script ... I found that the value I wanted was extracted so neatly 😲
python crawler.py
(out)15216074479.0
The potential of ChatGPT seems to be great
It is also likely to fully write the code that performs 100% of the task of the existing example, including the additional data desired to extract and data processing.
Web crawling work will also become a big use of ChatGPT in the future. I will finish the post by sharing the impressive words I saw in YouTube recently.
The most popular programming language in the future will be "English".