How to fetch these jokes locally ?

M4DM4X

Elite Member
Joined
Jan 21, 2015
Messages
2,909
Reaction score
1,753
Hi I have the script below that fetches jokes randomly from a websites and show them on mine.
I'd like to bypass the site and fetch the jokes from my own txt file (one joke per line and the script choose a random one to show on my site. Even if the jokes are not from this site in particular it's not a problem, I can scrape some jokes and put them myself in the txt file).
Do you know how I can do this guys please? (sorry for putting an image instead of text by I can't insert code for some reason it always triggers an error on the forum

script.jpg
 
Like this?
https://stackoverflow.com/questions/19706046/how-to-read-an-external-local-json-file-in-javascript
 
Thanks I will read this to improve my knowledge

theres many ways to solve this problem. this is how i personally solve it on my website.
bhw filters the code snippet for me too so check it out here https://hastebin.com/utodazayis.csharp

You're an angel mate thanks a lot to have taken the time to write this code for me that's exactly what I needed. I send you some positive karma thanks again you rock !
 
Thanks I will read this to improve my knowledge



You're an angel mate thanks a lot to have taken the time to write this code for me that's exactly what I needed. I send you some positive karma thanks again you rock !
no problem thank you for the karma i could use a lot these days

heres another tip how i handle this. it may help you too
my "jokes" file has 4000+ lines. i used excel to create it.
the spreadsheet looks like pic below. if youve used excel in a higher capacity previously, you likely know where this is headed. it's much faster than editing it in your favorite text editor.
clone rows A, C, E all the way down. Populate B with incrementing numbers. your jokes go in D.
once youre done with the spreadsheet contents, "select all" > "copy" > "paste" directly into your text editor

EXCEL_QgKZv5gsON.png
 
no problem thank you for the karma i could use a lot these days

heres another tip how i handle this. it may help you too
my "jokes" file has 4000+ lines. i used excel to create it.
the spreadsheet looks like pic below. if youve used excel in a higher capacity previously, you likely know where this is headed. it's much faster than editing it in your favorite text editor.
clone rows A, C, E all the way down. Populate B with incrementing numbers. your jokes go in D.
once youre done with the spreadsheet contents, "select all" > "copy" > "paste" directly into your text editor

View attachment 221284
Yep Excel is my go-to when manipulating text it saves a lot of time, the concatenate feature is great, and can be automated too. One of the few good things bill gates did :)
 
Back
Top