Share your repls and programming experiences

← Back to all posts
Teleport to a Random Webpage Because Why Not
SpicedSpices (145)

Have you ever wanted to just visit a random webpage without any knowledge of what is on it? Because if so, this is the perfect Repl for you.

I was bored at 1:47 AM this morning, so I came up with an idea. I decided to try to make a Repl that will redirect you to a completely random webpage. I didn't know how to come up with the random webpage though.

After some careful consideration, I decided on randomly generating a string with a random length, and searching it up in Bing to take the first link that shows up.

I don't know why I tried to do this, but I guess it is pretty cool.


Disclaimer:

Obviously random is not possible in the world of computing, so the way I found a 'random' webpage, was to create a random string with letters A-Z and numbers 0-9, and searching it up into Bing to take the first link that appeared.

Although not totally random, it still produces really weird websites.


Libraries / Frameworks

  • Express.JS for sending files and links to client.
  • HTTP for creating a server
  • Crawler for searching the web to take this links.

Code

Randomly Generated String
let length = Math.floor(Math.random()*(max+1-min))+min;
  let str = (Math.floor(Math.random()*36**length)+1).toString(36);
Redirect to External Website
res.status(301).redirect("https://www.youtube.com/watch?v=dQw4w9WgXcQ");

Disclaimer #2 ?

I used Bing to search things up because it is easier to find things in inspect element when this crawls the web.

Bing does have a safe search on by default, so this will be protected from any NSFW websites. Although it has safe search, that does not mean that there are malicious websites that might slip through the filter. Please while using this site, be cautious . If you would like, use a VPN, proxy, or a VM to make sure that no malicious websites will be bad for your computer.


Thank you for checking out this Repl.

If you enjoyed it, an upvote would always be appreciated. If not, please tell me how I could improve this Repl in the comments. Thanks :)

Commentshotnewtop
ChezCoder (1456)

this is a beautiful demonstration of the uses of web crawling, pseudo random, and many other aspects of programming, fit so snuggly in one project. Bravo, heres an upvote!

Edit, look what site i was sent to :/

Edit x2: Make a button and a input, the input contains a number, the button opens multiple webpages depending on the input. If the input were 4, then it opens 4 new webpages.

Edit x3: I will never forgive my self: http://v2mk.net/default.aspx

SpicedSpices (145)

wow thanks @ChezCoder i appreciate that :)

For Edit 1: Thats pretty secretive lol
For Edit 2: Ok that makes sense i'll have a cap on it though so no insane lag
For Edit 3: Bruh... glad i have a disclaimer :p that needs to be fixed

Codemonkey51 (756)

I got redirected to YouTube:)

AustinEntenmann (1)

Awesome, but strangely I keep getting pages about random biological molecules.

SpicedSpices (145)

@AustinEntenmann lol same yeah www.ncbi.nlm.nih.gov?

Commander07 (28)

Finally got redirected to google.

Commander07 (28)

Thanks SpicedSpices this website redirceted me to an automated download of Easy PowerPoint Recovery a software that costs 60 USD

Commander07 (28)

OH SNAP it downloaded an exe

Commander07 (28)

got redirected to an ps vita hack instant download

Commander07 (28)

LOL Got redirected to THIS post by it.

Commander07 (28)

i have been using this website for hours now. @PDanielY

Commander07 (28)

Got redirected to and automatic download anybody need Windows 8 UEFI Firmware Update from April 4 2013

ReaperZ0v (48)

very impressive :D
javascript is quite smooth, I'm a python developer but with that being said javascript is as special to me as python :)

SpicedSpices (145)

@ReaperZ0v thanks I appreciate that :D
yeah I like javascript because I like curly brackets and its syntax, but I really like the simplicity and intuitivity of python

ReaperZ0v (48)

@SpicedSpices awesome man! do check out my Repls :)

[deleted]

i made one with python

SpicedSpices (145)

@Zuhdi28 oh nice! what is it called?

[deleted]

@SpicedSpices i imported webbrowser

[deleted]

@SpicedSpices but on repl.it it doesn't owrk, but in VS code yes

Warhawk947 (507)

I got redirected to never gonna let you down meme

sigh

NoelB33 (284)

Weirdly I was taken to a random module on pypi...

SpicedSpices (145)

@NoelBryan lol thats a nice stroke of luck