Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python3
- #-*- coding: utf-8 -*-
- from bs4 import BeautifulSoup
- import urllib.request
- import os, random, re
- def removeEmptyLines(source_string):
- string_array = source_string.splitlines()
- new_string = ""
- for line in string_array:
- if '<' in line:
- new_string += line.replace("\t", "") + "\n"
- return new_string[:-1]
- def getRandomBashText():
- resp = urllib.request.urlopen("http://bash.org.pl/random/")
- soup = BeautifulSoup(resp, from_encoding=resp.info().get_param('charset'))
- for div in soup.find_all('div'):
- if "post-body" in str(div.get('class')):
- print(removeEmptyLines(div.get_text()))
- getRandomBashText()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement