Skip to content

Instantly share code, notes, and snippets.

@derricw
Created July 24, 2015 05:21
Show Gist options
  • Save derricw/fc4e2284633f480cf706 to your computer and use it in GitHub Desktop.
Save derricw/fc4e2284633f480cf706 to your computer and use it in GitHub Desktop.
prints a random youporn comment
from random import randrange
import re
import urllib
for i in range(5):
sock = urllib.urlopen("http://www.youporn.com/random/video/")
htmlSource = sock.read()
sock.close()
result = re.findall('<p class="message">((?:.|\\n)*?)</p>', htmlSource)
if len(result)>0:
print "----" + result[randrange(len(result))] + "----"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment