Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Simple parser
- from bs4 import BeautifulSoup
- import urllib.request
- import urllib.parse
- def find_pastes(pastebin_link):
- if 'https://pastebin.com/' not in pastebin_link:
- print("Sorry, {} is not a valid link!".format(pastebin_link))
- else:
- try:
- raw_link = pastebin_link.replace('.com', '.com/raw/')
- raw_link = raw_link.replace('raw//', 'raw/')
- page = urllib.request.Request(raw_link)
- page = urllib.request.urlopen(page)
- html_doc = page.read()
- soup = BeautifulSoup(html_doc, 'html.parser')
- print(soup.text)
- """
- You could also
- edit it to
- download the
- paste's text,
- if you wanted to.
- """
- except Exception:
- print("There was an error loading your pastebin.")
Advertisement
Add Comment
Please, Sign In to add comment