Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python3
- from bs4 import BeautifulSoup
- import requests
- import re
- head = {"Cache-Control": "no-cache",
- "Pragma": "no-cache",
- "Expires": "Thu, 01 Jan 1970 00:00:00 GMT"
- }
- doc = requests.get("http://danstonchat.com/random0.html", headers=head)
- if doc.status_code != 200:
- exit()
- soup = BeautifulSoup(doc.content, "html.parser")
- fst = soup.find_all("div", class_="item", limit=1)
- quote = fst[0].find("a")
- while quote.br is not None:
- quote.br.replace_with("\n")
- str = re.sub("\n ", "\n", quote.get_text())
- print(str)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement