import signal
import urllib2
from bs4 import BeautifulSoup
def handler (signum,frame):
print "rppost over time!"
exit()
def post(url):
try:
req = urllib2.Request(url)
req.add_header('User-Agent','Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.73 Safari/537.36')
req.add_header('Connection','keep-alive')
req.add_header('Accept','text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8')
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
signal.signal(signal.SIGALRM,handler)
signal.alarm(3)
response = opener.open(req)
signal.alarm(0)
return response.read()
except:
return ""