Problemas de raspado de web VBA

Estoy construyendo un raspador web de VBA para get todos los nombres de un artículo y los precios de un artículo. Soy muy nuevo en VBA y tengo problemas con los detalles finales de esta consulta.

Quiero que acceda al website de este cuchillo, tome el nombre y el precio y almacénelos en la hoja, pase al siguiente artículo, y una vez que haya terminado en esa página, continúe en las siguientes páginas hasta que todos los artículos hayan sido raspados. ¿Alguien puede señalar los errores que estoy cometiendo al completar este progtwig?

Sub printnumbs() ' Dim i As Integer For i = 0 To 10 Range("D6").Offset(0, (i * 2)).Value = i + 2 Next i ' End Sub Sub scrape() Dim i2 As Integer Dim ie As Object Set ie = CreateObject("InternetExplorer.Application") With ie .Visible = True For i2 = 1 To 2 'Max is For i2 = 0 To 400 .navigate "https://www.knifecenter.com/kc_new/store_store.html?ttl=Hunting%20and%20Bushcraft%20Knives&desc=Hunting%20Bushcraft&wnWWWCAT_1datarq=video&wnWWWCAT_1datarq=notepad&s=" & (i2 + (i2 * 30)) Application.Wait (Now + TimeValue("0:00:02")) Do DoEvents Loop Until ie.readyState = READYSTATE_COMPLETE Dim doc As HTMLDocument Set doc = ie.document While ie.readyState <> 4 Wend On Error Resume Next Dim i As Integer For i = 0 To 29 Range("B9").Offset(i + (i2 * 30), (0)).Value = doc.getElementsByClassName("maincontent")(0).getElementsByClassName("product_listing")(0).getElementsByClassName("row-fluid")(0).getElementsByClassName("listing_item span4")(0).getElementsByClassName("price-row")(0).getElementsByClassName("left-col")(0).innerText Range("C9").Offset(i + (i2 * 30), (0)).Value = doc.getElementsByClassName("maincontent")(0).getElementsByClassName("product_listing")(0).getElementsByClassName("row-fluid")(0).getElementsByClassName("listing_item span4")(0).getElementsByClassName("price-row")(0).getElementsByClassName("product_name")(0).innerText Next i Next i2 ie.Quit Application.EnableEvents = True End With ' End Sub 

Dale una oportunidad. Cuando hay un método robusto, ¿por qué quedarse con IE? No debería tomar más de 5 segundos get todos los datos:

 Sub Web_Data() Const URL As String = "https://www.knifecenter.com/kc_new/store_store.html?ttl=Hunting%20and%20Bushcraft%20Knives&desc=Hunting%20Bushcraft&wnWWWCAT_1datarq=video&wnWWWCAT_1datarq=notepad&s=" Dim http As New XMLHTTP60, html As New HTMLDocument, page As Long, row As Long Dim topic As HTMLHtmlElement For page = 1 To 151 Step 30 With http .Open "GET", URL & page, False .send html.body.innerHTML = .responseText End With For Each topic In html.getElementsByClassName("listing_item span4") With topic.getElementsByClassName("product_name") If .Length Then row = row + 1: Cells(row, 1) = .Item(0).innerText End With With topic.getElementsByClassName("our_price") If .Length Then Cells(row, 2) = .Item(0).innerText End With Next topic Next page End Sub 

Referencia para agregar a la biblioteca:

 1. Microsoft HTML Object Library 2. Microsoft XML, V6.0 ''Or whatever version you have 

¿Por qué necesitaría VBA personalizado para get datos de un sitio como este? El código requerido para automatizar el process no funcionaría en otros sitios (ya que cada sitio se configura de manera diferente) y no valdría la pena el time de desarrollar y mantener el código. Definitivamente no es un proyecto para principiantes.

A veces, copyr y pegar bien hace el truco bien. Go to web page, CTRL+A CTRL+C, Right Click in Excel, Paste Special, Text. Repeat. Cuando termine, elimine las filas que no necesita o cree fórmulas simples para decir qué filas tienen sus datos.

Aquí está todo el "Nombre + Precio" de las 6 páginas en el enlace que envió. Me tomó más time escribir esta respuesta de la que obtuvo para get los datos :

 "Bark River Knives Bushcrafter Fixed 3.25 inch CPM-154 Blade, Black Canvas Micarta Handles, Leather Sheath";219.95 "Bark River Knives Bushcrafter II Fixed 4.7 inch CPM-3V Blade, Antique Ivory Micarta Handles, Leather Sheath";239.95 "Bark River Knives Bushcrafter II Fixed 4.7 inch CPM-3V Blade, Black Canvas Micarta Handles, Leather Sheath";234.95 "Bark River Knives Bushcrafter II Fixed 4.7 inch CPM-3V Blade, Bocote Wood Handles, Leather Sheath";256.95 "Bark River Knives Bushcrafter II Fixed 4.7 inch CPM-3V Blade, Green Canvas Micarta Handles, Leather Sheath";239.95 "Bark River Knives Ultra-Lite Bushcrafter Fixed 3.25 inch CPM-3V Blade, Black Canvas Micarta Handles, Leather Sheath";188.95 "Bark River Knives Ultra-Lite Bushcrafter Fixed 3.25 inch CPM-3V Blade, Bocote Wood Handles, Leather Sheath";209.95 "Bark River Knives Ultra-Lite Bushcrafter Fixed 3.25 inch CPM-3V Blade, Green Canvas Micarta Handles, Leather Sheath";196.95 "Benchmade 162-1 Bushcrafter Fixed 4.43 inch S30V Satin Blade, Sand G10 Handles, Kydex Sheath";182.75 "Boker Arbolito Dano Hunting Knife Fixed 8.5 inch N695 Blade, Guayacan Wood Handles, Leather Sheath";92.95 "Boker Arbolito El Gigante Hunting Knife Fixed 8.375 inch Stonewash Blade, Green Micarta Handles, Leather Sheath";146.95 "Boker Arbolito Nicker Hunting Knife 3-3/4 inch Fixed Blade, Stag Handles";82.36 "Boker Folding Hunting Knife 5.25 inch Closed, Stag Handles";194.95 "Boker Plus Bushcraft Next Generation Fixed 4 inch Drop Point Blade, Micarta Handles, Leather Sheath";59.96 "Boker Plus Bushcraft XL Fixed 4.375 inch Satin Blade, Orange G10 Handles";92.95 "Boker Plus Optima Hunting Set with Gut Hook, Saw Blade, Leather Sheath";51.95 "Boker Savannah Hunting Knife Fixed 4.625 inch N690 Two-Tone Blade, Micarta Handles, Leather Sheath";229.95 "Boker Savannah Hunting Knife Fixed 4.625 inch N690 Two-Tone Blade, Stag Handles, Leather Sheath";250.95 "Boker Savannah Hunting Knife Fixed 4.65 inch N690 Two-Tone Blade, Ram Horn Handles, Leather Sheath";236.95 "Browning Overtime Hunting Knife Fixed 3.6 inch D2 Satin Plain Blade, Green G10 Handles, Leather Sheath";86.95 "Browning Overtime Hunting Knife Fixed 3.6 inch D2 Satin Plain Blade, Tan G10 Handles, Leather Sheath";86.95 "Browning Speed Load Replaceable Hunting Blades, 50 Pack";28.95 "Buck 071 Kinetic Hunting Spearhead 2.5 inch Blade, Stainless Steel Handle";35.95 "Buck 119 Special 75th Anniversary Hunting Knife 6 inch Satin Blade, Black Phenolic Handle, Black Leather Sheath";59.95 "Buck 119BR Special 75th Anniversary Hunting Knife 6 inch Satin Blade, Cocobola Dymondwood Handle, Burgundy Leather Sheath";79.95 "Buck 120 General Hunting Knife Fixed 7-3/8 inch Blade, Black Phenolic Handles";76.95 "Buck 120 General Hunting Knife Fixed 7-3/8 inch Blade, Cocobola Dymondwood Handles";89.95 "Buck 191BR Zipper Hunting Knife Fixed 4-1/4 inch Blade with Gut Hook, Rubber Handle, Nylon Sheath";69.95 "Buck 191BR Zipper Hunting Knife Fixed 4-1/4 inch Blade with Gut Hook, Walnut Handle, Leather Sheath";85.95 "Buck 495 ErgoHunter Hunting Knife Fixed 4-3/4 inch 420HC Blade with Gut Hook, Alcryn Rubber Handles (0495BKG)";59.95 "Buck 673 BuckLite MAX Small Hunting Knife 3-1/4 inch 420HC Blade";18.95 "Buck 679 BuckLite MAX Large Hunting Knife 4 inch 420HC Blade";23.95 "Buck 679 BuckLite MAX Large Hunting Knife 4 inch 420HC Blade with Guthook";27.95 "Buck 679 BuckLite MAX Large Hunting Knife 4 inch Blade with Guthook, Orange Textunetworking Alcryn Rubber Handles";29.95 "Buck 679 BuckLite MAX Large Hunting Knife 4 inch Blade, Orange Textunetworking Alcryn Rubber Handles";23.95 "Camillus Bushcrafter USA Survival Fixed 4 inch 1095 Carbon Blade, Micarta Handle, Leather Sheath";77.95 "Camillus Carnivore 12 inch Titanium Bonded Fixed Blade Knife with Camo Handles";3 "Case Twin Finn Two Piece Hunting Set, Leather Handles, Leather Sheath";114.98 "Cold Steel 97GMS Gladius Machete 19 inch Blade, Polypropylene Handle, Cor-Ex Sheath";4.5 "Cold Steel 97KMS Kukri Machete 13 inch Blade, Polypropylene Handle, Cor-Ex Sheath";4.5 "Cold Steel 97MKM Magnum Kukri Machete 17 inch Blade, Polypropylene Handle, Cor-Ex Sheath";4 "Condor Tool & Knife CTK236-4HC Bushcraft Basic Camp Knife 4 inch Carbon Steel Black Blade, Hardwood Handle, Leather Sheath";50.98 "Condor Tool & Knife CTK236-5HC Bushcraft Basic Camp Knife 5 inch Carbon Steel Black Blade, Hardwood Handle, Leather Sheath";55.23 "Condor Tool & Knife CTK256-4.5HC Hivernant Hunting Knife 4-1/2 inch Satin Stainless Steel Blade, Hardwood Handles, Leather Sheath";43.95 "Condor Tool & Knife CTK410-14HCS Golok Machete 14 inch Black Carbon Steel Blade, Walnut Handles, Leather Sheath";4.5 "Condor Tool & Knife CTK412-17HCS Parang Machete 17-1/2 inch Carbon Steel Black Blade, Hardwood Handles, Leather Sheath";4.5 "Condor Tool & Knife CTK423-13HC Bushcraft Parang Machete 13 inch Carbon Steel Blade, Polypropylene Handles, Nylon Sheath";63.73 "Down Under Knives The Mistress Bowie Hunting Knife 13 inch Polished Blade, Leather Handle";249.95 "Down Under Knives The Outback Hunting Bowie Knife 11 inch Polished Blade, Leather Handle";199.95 "ESEE Knives Junglas Machete 10.38 inch Black Blade, Micarta Handles, Kydex Sheath";5 "Fremont Knives Farson Hunting Combo, Hatchet and Hide Glider Set";63.95 "Gerber Freeman Guide Hunting Knife Fixed 4 inch Bead Blast Plain Blade with Gut Hook, TacHide Handles, Nylon Sheath";20.76 "Gerber Freeman Guide Hunting Knife Fixed 4 inch Bead Blast Plain Blade, TacHide Handles, Nylon Sheath";20.76 "Gerber Moment Hunting Kit 2 Fixed Saw and Guthook Knife, Nylon Sheath";35.16 "Gerber Moment Hunting Kit 3 Fixed Saw, Caping and Guthook Knives, Nylon Sheath";59.95 "Grohmann Original Design Hunting Belt Knife 4 inch Blade, Rosewood Handles";89.95 "Grohmann Original Design Hunting Belt Knife 4 inch Blade, Stag Handles";124.76 "Havalon Hydra Double-Bladed Hunting Knife, 7 Blade Styles #60A, #70A, #22XT, #22, #127XT, #115XT and #115SW, Green Aluminum Handles";74.99 "Havalon Hydra Double-Bladed Hunting Knife, 7 Blade Styles #60A, #70A, #22XT, #22, #127XT, #115XT and #115SW, Red Aluminum Handles";74.99 "Havalon Titan Pro Replaceable Double-Bladed Hunting Knife, Gray Aluminum Handles with Black Inlays, Nylon Sheath";59.99 "Havalon Titan Replaceable Double-Bladed Hunting Knife, Black/Red Zytel Handles, Nylon Sheath";52.49 "Havalon Titan Replaceable Double-Bladed Hunting Knife, Blaze Orange Handles, Nylon Sheath";52.49 "Helle Brakar Hunting Knife 5 inch Blade, Curly Birch and Walnut Handle, Leather Sheath";149 "Helle Eggen Hunting Knife 4 inch Blade, Curly Birch Handle, Leather Sheath";109 "Helle Fjellkniven Hunting Knife 4 inch Blade, Curly Birch Handle, Leather Sheath";114 "Helle Harding Hunting Knife 4 inch Blade, Walnut and Curly Birch Handle, Leather Sheath";134 "Helle Lappland Hunting Knife 8-3/8 inch Blade, Birch Handle, Leather Sheath";169 "Helle Nying Hunting Knife 3 inch Blade, Curly Birch Handle, Leather Sheath";94 "Helle Odel Birch Hunting Knife 3-1/2 inch Blade, Stag Horn and Leather Handles, Leather Sheath";134 "Helle Symfoni Hunting Knife 3-1/2 inch Blade, Curly Birch, Stag Horn and Leather Handle, Leather Sheath";109 "Hubertus Hunting Cutlass 10.25 inch Satin Blade, Stag Handles with Silver Plating";507.96 "Hunting";Other Lock Types "KA-BAR 1249 Kukri Machete 11-1/2 inch Blade, Kraton G Handle, Leather / Cordura Sheath";4.5 "Kellam Knives Finnish Ranger Puukko M.95 Fixed Blade Forged Carbon Steel Hunting Knife";149.95 "Ken Onion Knifeworks Special Edition 6 inch Hunting/Fishing/Skinning/Fillet Knife, Polished G10 Handles, Leather Sheath, KnifeCenter Exclusive";139.95 "Kizlyar Supreme Echo Hunting Fixed 4.5 inch Niolox Satin Plain Blade, Black/White Micarta Handles, Kydex Sheath";125.95 "LionSteel M4 G10 Bushcrafting Fixed 3.74 inch Satin M390 Plain Blade, Black G10 Handles, Leather Sheath";155.99 "LionSteel M4 ST Bushcrafting Fixed 3.74 inch Satin M390 Plain Blade, Santos Wood Handles, Leather Sheath";155.99 "LionSteel M4 UL Bushcrafting Fixed 3.74 inch Satin M390 Plain Blade, Olive Wood Handles, Leather Sheath";155.99 "LionSteel M4 WN Bushcrafting Fixed 3.74 inch Satin M390 Plain Blade, Walnut Wood Handles, Leather Sheath";171.99 "Marttiini Lynx 121 Hunting Knife 3.54 inch Fixed Plain Blade, Curly Birch Handle, Leather Sheath";43.95 "Marttiini Lynx 131 Hunting Knife Fixed 4-1/4 inch Blade, Curly Birch Wood Handle";49.95 "Marttiini Lynx 139 Hunting Knife Fixed 5-1/8 inch Blade, Curly Birch Wood Handle";47.16 "Marttiini Ranger 250 Hunting Knife Fixed 6-1/4 inch Blade, Birch Wood Handle";95.95 "Maserin 181/CV Folding Hunting Knife 3 inch Polished Blade, Stag Handles";219.95 "Maserin 181/MC Folding Hunting Knife 3 inch Polished Blade, White and Blue Micarta Handles";159.96 "Maserin 976/G10A Croz Hunting Knife Fixed 4.375 inch N690 Satin Combo Blade, Orange G10 Handles, Black Nylon Sheath";144.95 "Maserin 976/G10N Croz Hunting Knife Fixed 4.375 inch N690 Satin Combo Blade, Black G10 Handles, Black Nylon Sheath";144.95 "Maserin 976/MCV Croz Hunting Knife Fixed 4.375 inch N690 Satin Combo Blade, Green G10 Handles, Black Nylon Sheath";144.95 "Morakniv Mora of Sweden Black Bushcraft Fixed 4.3 inch Carbon Steel Plain Blade, Black Rubberized Handle, MOLLE Sheath";89.99 "Morakniv Mora of Sweden Black Bushcraft Fixed 4.3 inch Stainless Steel Combo Blade, Black Rubberized Handle, MOLLE Sheath";89.99 "Morakniv Mora of Sweden Black Bushcraft Fixed 4.3 inch Stainless Steel Combo Blade, Black Rubberized Handle, Plastic Sheath";37.56 "Morakniv Mora of Sweden Black Bushcraft Fixed 4-1/4 inch Carbon Steel Blade, Black Rubberized Handle, Plastic Sheath";49.99 "Morakniv Mora of Sweden Black Bushcraft Fixed 4-1/4 inch Stainless Steel Combo Blade, Black Rubberized Handle, Plastic Sheath";49.99 "Morakniv Mora of Sweden Black Bushcraft Knife 4.3 inch Carbon Steel Blade, Black Rubber Handle";49.99 "Morakniv Mora of Sweden Black Bushcraft Pathfinder Fixed 6-3/4 inch Carbon Steel Blade, Black Rubberized Handle, MOLLE Compatible Heavy-Duty Nylon Sheath";89.99 "Morakniv Mora of Sweden Bushcraft Survival Knife 4-1/8 inch Black Carbon Steel Blade, Fire Starter and Sheath, Black Rubberized Handle";69.99 "Morakniv Mora of Sweden Forest Bushcraft Fixed 4 inch Stainless Steel Blade, Green Rubberized Handle, Plastic Sheath";37.95 "Morakniv Mora of Sweden Orange Bushcraft Fixed 4-1/4 inch Stainless Steel Blade, Orange Rubberized Handle, Plastic Sheath";37.95 "Ontario Bushcraft Field Knife Fixed 5 inch 5160 Carbon Blade, Walnut Wood Handles, Nylon Sheath";64.95 "Ontario Bushcraft Machete 16 inch 5160 Carbon Blade, Walnut Wood Handle, Nylon Sheath";74.95 "Ontario Bushcraft Machete 16 inch 5160 Carbon Blade, Walnut Wood Handle, Original DeSantis Nylon Sheath";98.95 "Ontario Bushcraft Machete Smooth Black Powdercoat 16 inch 5160 Carbon Blade, Walnut Wood Handle, DeSantis Nylon Sheath";99.95 "Ontario Bushcraft Utility Fixed 4 inch Carbon Steel Blade, Walnut Wood Handles, Nylon Sheath";64.95 "Ontario Bushcraft Utility Fixed 4 inch Carbon Steel Blade, Walnut Wood Handles, Original DeSantis Sheath";83.95 "Ontario Bushcraft Woodsman Fixed 9.18 inch 5160 Carbon Steel Blade, Walnut Wood Handles, Nylon Sheath";74.95 "Ontario Military Jungle Machete 18 inch Blade";4.5 "Ontario Nylon Sheath by DeSantis Gunhide Fits 6527 Bushcraft Utility";31.95 "Ontario Ranger Series Falcon Hunting Knife 3.875 inch Carbon Steel Blade, Micarta Handles, Nylon Sheath";64.95 "Ontario Ranger Series Falcon Hunting Knife 3-7/8 inch Carbon Steel Blade, Micarta Handles, Original Nylon Sheath";79.95 "Ontario Sawback Machete 18 inch Blade";4.5 "Outdoor Edge Dark Timber Skinner-Caper Hunting Knife Combo, Pakkawood Handles, Leather Sheath";49.99 "Outdoor Edge SwingBlade Hunting Knife, Two Blades in One, Black TPR Handle, Nylon Sheath";49.95 "Outdoor Edge SwingBlaze Hunting Knife, Two Blades in One, Orange TPR Handle, Nylon Sheath";49.95 "Outdoor Edge The Outfitter, 7 Piece Hunting Tool Set in Nylon Roll Case";92.95 "Outdoor Edge Zip-Blade Hunting Knife Fixed 4 inch Gutting Blade, Orange TPR Handles, Black Nylon Sheath";13.99 "RealSteel Knives Bushcraft II Fixed 4.125 inch D2 Plain Blade, Black G10 Handles, Kydex Sheath";54.8 "Reproduction Hunting Flintlock Dagger Pistol With Wood Grips";47.95 "Rockstead KEI-ZDP Japanese Hunting Knife Fixed 3.625 inch ZDP-189 Mirror Finish Blade, White Micarta Handles";0 "Schrade Bolo Machete 14 inch 3Cr13 Stainless Blade, Safe-T-Grip Handle, Ferro Fire Steel and Sharpening Stone";4.5 "Shadow Tech Gear2Survive Bushcraft Knife Fixed 4.38 inch Black Blade, Black Canvas Micarta Handles, Kydex Sheath";0 "Shadow Tech Gear2Survive Bushcraft Knife Fixed 4.38 inch Black Blade, Green Canvas Micarta Handles, Kydex Sheath";0 "Shadow Tech Gear2Survive Bushcraft Knife Fixed 4.38 inch Flat Dark Earth Blade, Black Textunetworking G10 Handles, Kydex Sheath";0 "Shadow Tech Gear2Survive Bushcraft Knife Fixed 4.38 inch OD Green Blade, Black Textunetworking G10 Handles, Kydex Sheath";0 "Spyderco FB26GP Bushcraft Survival Knife Fixed 4 inch Blade, Black G10 Handles";209.97 "TOPS Knives BOB Brothers of Bushcraft Fieldcraft Fixed 4.75 inch 154CM Blade, Black G10 Handles, Kydex Sheath";174.95 "TOPS Knives BOB Brothers of Bushcraft Fieldcraft Fixed 4.75 inch 154CM Blade, Black Linen Micarta Handles, Kydex Sheath";174.95 "TOPS Knives BOB Brothers of Bushcraft Fieldcraft Fixed 4.75 inch 154CM Blade, Black/White G10 Handles";174.95 "TOPS Knives BOB Brothers of Bushcraft Fieldcraft Fixed 4.75 inch 154CM Blade, Blue/Black G10 Handles";174.95 "TOPS Knives BOB Brothers of Bushcraft Fieldcraft Fixed 4.75 inch 154CM Blade, Green/Black G10 Handles";174.95 "TOPS Knives BOB Brothers of Bushcraft Fieldcraft Fixed 4.75 inch 154CM Blade, Red/Black G10 Handles";174.95 "TOPS Knives BOB Brothers of Bushcraft Fieldcraft Fixed 4.75 inch 154CM Blade, Tan Canvas Micarta Handles, Kydex Sheath";174.95 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Blade, Black G10 Handles";119.96 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Blade, Black Linen Micarta Handles";149.95 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Blade, Brown Micarta Handles";149.95 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Blade, Green/Black G10 Handles";149.95 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Blade, Red/Black G10 Handles";149.95 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Carbon Blade, White/Black G10 Handles";149.95 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Stonewashed Blade, Brown Micarta Handles";149.95 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Tan Blade, OD Green Micarta Handles";149.95 "TOPS Knives BOB Brothers of Bushcraft Hunter 4-5/8 inch 1095 Tumbled Blade, Gray Linen Micarta Handles";149.95 "TOPS Knives BOB Brothers of Bushcraft Hunter Articulating Brown Leather Sheath, Ferro Rod, Survival Whistle";46.95 "TOPS Knives Nicholas Fury Bushcrafter Kukuri 7.0 Fixed 7-3/4 inch 1095 Kukri Blade, Micarta Handles (BKUK-01)";188.95 "TOPS Knives Wind Runner SRE Hunting Fixed Blade Combo Set, Green Micarta Handles, Black Kydex Sheath";209.95 "United Cutlery Bushmaster Bushcraft Primitive Field Knife 5.31 inch Drop Point Blade, Wood Handles, Leather Sheath";39.95 "United Cutlery Bushmaster Bushcraft Tactical Field Knife 5.31 inch Black Drop Point Blade, TPR Handles, Nylon Sheath";24.95 "United Cutlery Gil Hibben Master Bushcraft Machete 11.19 inch 1075 Plain Blade, Walnut Wood Handles, Nylon Sheath";78.95 "Utica Adirondack Hunting Knife Fixed 3-5/8 inch 420 Stainless Blade, Cocobola Wood Handles";49.95 "Utica Catskill Hunting Knife Fixed 2-3/4 inch 1095 Carbon Steel Blade, Brown Bone Handles";53.95 "Utica Catskill Hunting Knife Fixed 3-5/8 inch Carbon Steel Blade, Brown Jigged Bone Handles";46.36 

¿Sabes cómo copyr los datos desde aquí a Excel?

Este sitio no es el más fácil de raspar. Para ahorrar time, repetí todos los divs con class="listing_item span4" y analicé su innerText.

Te recomiendo que mires estos videos:

  • Excel VBA Introducción Parte 5 – Selección de celdas (range, celdas, celda activa, final, desplazamiento)
  • Excel VBA Introducción Parte 47 – Navegación a sitios web y raspado de una página web
  • Excel VBA Introducción Parte 48 – Web Scraping en varias páginas

enter image description here

 Sub scrape() Dim URL As String Dim aNext As HTMLAnchorElement, div As HTMLDivElement, doc As HTMLDocument URL = "https://www.knifecenter.com/kc_new/store_store.html?ttl=Hunting%20and%20Bushcraft%20Knives&desc=Hunting%20Bushcraft&wnWWWCAT_1datarq=video&wnWWWCAT_1datarq=notepad&s=1" Set IE = CreateObject("InternetExplorer.Application") IE.Visible = True Do IE.navigate URL Do DoEvents Loop Until IE.readyState = READYSTATE_COMPLETE Set doc = IE.document For Each div In doc.getElementsByClassName("listing_item span4") ProcessDiv div Next URL = "" On Error Resume Next URL = doc.getElementsByClassName("next")(0).href On Error GoTo 0 Loop Until Len(URL) = 0 IE.Quit Application.EnableEvents = True End Sub Private Sub ProcessDiv(div As HTMLDivElement) Dim Name As String Dim arr As Variant Dim Price As Double arr = Split(div.innerText, vbCrLf) Name = arr(4) Price = arr(8) AppendProduct Name, Price End Sub Private Sub AppendProduct(Name As String, Price As Double) With Worksheets("Sheet1") With .Range("A" & .Rows.Count).End(xlUp).Offset(1) .Cells(1, 1).Value = Name .Cells(1, 2).Value = Price End With End With End Sub