VetExc
Destek Ekibi
- Katılım
- 5 May 2021
- Mesajlar
- 924
- Çözümler
- 372
- Aldığı beğeni
- 1,666
- Excel V
- Office 2016 TR
Deneyin.
Yada şöyle deneyin.
C++:
Sub ExtractData()
Dim http As New MSXML2.XMLHTTP
Dim html As String
Dim price As String
'Send GET request to the webpage
http.Open "GET", "https://www.amazon.com.tr/RODE-Wireless-GO-II-mikrofon/dp/B08XFQ6KP9/ref=sr_1_3?__mk_tr_TR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=3UONC668WJ2PL&keywords=wireless+go+ii&qid=1660821745&sprefix=wireless+go+ii%2Caps%2C138&sr=8-3", False
http.send
'Get the response
html = http.responseText
'Extract the price
price = ExtractPrice(html)
'Write the price to cell C3
Range("C3").Value = price
End Sub
Function ExtractPrice(html As String) As String
Dim doc As New HTMLDocument
doc.body.innerHTML = html
ExtractPrice = doc.getElementsByClassName("a-price-whole")(0).innerText
End Function
Yada şöyle deneyin.
C++:
Sub ExtractData()
Dim http As New WinHttpRequest
Dim html As String
Dim price As String
'Send GET request to the webpage
http.Open "GET", "https://www.amazon.com.tr/RODE-Wireless-GO-II-mikrofon/dp/B08XFQ6KP9/ref=sr_1_3?__mk_tr_TR=%C3%85M%C3%85%C5%BD%C3%95%C3%91&crid=3UONC668WJ2PL&keywords=wireless+go+ii&qid=1660821745&sprefix=wireless+go+ii%2Caps%2C138&sr=8-3", False
http.send
'Get the response
html = http.responseText
'Extract the price using regular expression
price = ExtractPrice(html)
'Write the price to cell C3
Range("C3").Value = price
End Sub
Function ExtractPrice(html As String) As String
Dim price As String
Dim regEx As New RegExp
'Set the regular expression pattern
regEx.Pattern = "\$\d+\.\d+"
'Execute the regular expression
Set regExMatches = regEx.Execute(html)
'Check if a match was found
If regExMatches.Count > 0 Then
'Get the first match
price = regExMatches(0)
Else
'No match found
price = "Not found"
End If
ExtractPrice = price
End Function