In the work, Excel is often used for work assistance, tabulation, statistics, and summary. In fact, Excel has a more powerful function than formulas, that is, VBA. You can use VBA to program to achieve complex functions other than formulas.
Use the following example to briefly introduce how to use VBA to crawl.
Sub HTTPREQUEST()
Dim httpReq As XMLHTTP60
Set httpReq = New XMLHTTP60
Dim Content As String
Dim arr1() As String
Dim arr2() As String
Dim arr3() As String
Dim arr4() As String
httpReq.Open "GET", "https://nihongokyoshi-net.com/2019/07/03/jlptn1-grammar-ikan/"
httpReq.Send
Do While httpReq.readyState < 4
DoEvents
Loop
Debug.Print httpReq.responseText
Content = httpReq.responseText
arr1 = Split(Content, "<section class=""single-post-main"">")
arr2 = Split(arr1(1), "</section>")
arr3 = Split(arr2(0), "<span id=""i"">")
arr4 = Split(arr3(1), "</span>")
Sheet1.Cells(1, 1) = arr4(0)
arr3 = Split(arr2(0), "<span class=""s1"">")
arr4 = Split(arr3(1), "</span>")
Sheet1.Cells(2, 1) = arr4(0)
Set httpReq = Nothing
End Sub
There are more complicated methods, such as multithreading, which will be introduced later.