GUIDE: Using Switch Statement #64
dynabler
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Scenario: You want to check for data, but not save the actual data. Instead, you want to save it as your interpretation of data.
For example: You need to know if a page actually exists, but the server doesn't give a hard 404. It rather gives a soft 404 “page does not exist”.
When scraping this type of pages, your final JSON will have
status: page does not exist
. We want it to be more clean.The following example checks Twitter for account status and outputs a JSON with status as we see fit.
Using a JavaScript Switch statement, we can return/save data as we see fit.
Beta Was this translation helpful? Give feedback.
All reactions