Error 91 while scraping web

evd46

New Member
Joined
Apr 8, 2013
Messages
2
With this vba-code :
If Not DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa") Is Nothing Then
Failure = DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText 'Failure being declared as an object
End If

I want to scrape data from this piece of HTML-code :
<ul class="borderSection_toolbar icon-prepa">
<li id="ContentPlaceHolder_trPrepa">Préparation
<span id="ContentPlaceHolder_LblRecetteTempsPrepa">15 min</span>
</li>
<li class="hide-for-small-only">
<button type="button" class="button dark border icon-step" data-stepper></button>
</li>
</ul>

Yet it produces a #91-error.
The code following this test gives the same error :
Debug.Print "Temps de préparation : " & Left(DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText, Len(DishesDoc.getElementById("ContentPlaceHolder_LblRecetteTempsPrepa").innerText) - 4) & " minutes".

As this latter code works fine for most of the similar yet not identically coded pages, I want to avoid the code to crash on the differently coded pages.
PS: I tried to use the on error resume next and the on error goto errorhandler, but also these do not work.

How can I best solve these problems?
 

Excel Facts

Whats the difference between CONCAT and CONCATENATE?
The newer CONCAT function can reference a range of cells. =CONCATENATE(A1,A2,A3,A4,A5) becomes =CONCAT(A1:A5)
How can I best solve these problems?
Hi, start with a complete elaboration like any Excel forum expects for ! In order there is nothing to guess …​
You can try some Debug.Print codelines on each web element to find out where the error raises.​
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top