Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by antonioking
at 2024-08-30 04:12:50
Point:500 Replies:3 POST_ID:829207USER_ID:12084
Topic:
VB Script;Visual Basic Programming;Microsoft Excel Spreadsheet Software
Using some vb code to extract some information out of a website
Occasionally the website goes down, and presents a 504 error page.
The element I'm trying to extract is not present on the 504 page.
How can I edit my code so it only extracts the information if it actually exists?
Thanks in advance
Occasionally the website goes down, and presents a 504 error page.
The element I'm trying to extract is not present on the 504 page.
How can I edit my code so it only extracts the information if it actually exists?
Thanks in advance
Set TDelements = HTMLdoc.getElementById("menu_content").getElementsByTagName("TD") 1:
Author: antonioking replied at 2024-09-04 06:37:36
Thank you both for your help
Accepted Solution
Expert: MlandaT replied at 2024-08-30 07:15:47
250 points EXCELLENT
Set MenuElement = HTMLdoc.getElementById("menu_content")If MenuElement Is Nothing Then Set TDelements = NothingElse Set TDelements = MenuElement.getElementsByTagName("TD")End If'Make sure to check TDElements is not nothing before you use itIf Not TDElements Is Nothing Then 'Do your thing here.End If 1:2:3:4:5:6:7:8:9:10:11:12:13:14:
However, I think the best is for you to check for the 504 when you load HTMLdoc. That way, you don't even go as far as trying to parse the HTML soon as you realise that the site is down. It is however still good practice to do lots of error checking and try to avoid making assumptions that (for example) the menu_element will always be there.
Assisted Solution
Expert: rwniceing replied at 2024-08-30 04:25:08
250 points EXCELLENT
Probably you want it on VBA on Excel, Right ? if so, test following code
to check object ID first before any info extraction
to check object ID first before any info extraction
set obj= HTMLdoc.getElementById("menu_content")If obj Is Nothing Thendebug.print "obj not exist"Elsedebug.print "obj exist"End If 1:2:3:4:5:6:7: