Guest User

Untitled

a guest
Mar 23rd, 2016
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/python3
  2.  
  3. #-*- coding: utf-8 -*-
  4. from bs4 import BeautifulSoup
  5. import urllib.request
  6. import os, random, re
  7.  
  8. def removeEmptyLines(source_string):
  9.     string_array = source_string.splitlines()
  10.     new_string = ""
  11.     for line in string_array:
  12.         if '<' in line:
  13.            
  14.             new_string += line.replace("\t", "") + "\n"
  15.     return new_string[:-1]
  16.  
  17. def getRandomBashText():
  18.     resp = urllib.request.urlopen("http://bash.org.pl/random/")
  19.     soup = BeautifulSoup(resp, from_encoding=resp.info().get_param('charset'))
  20.  
  21.     for div in soup.find_all('div'):
  22.         if "post-body" in str(div.get('class')):
  23.             print(removeEmptyLines(div.get_text()))
  24.    
  25.  
  26. getRandomBashText()
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×