Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/data/data/com.termux/files/usr/bin/python3
- # -*- coding: utf-8 -*-
- import requests
- from bs4 import BeautifulSoup
- import re
- URL = input("Enter your Finalogy Article url name:")
- EX1 = ".txt"
- Fn = "NewFilename"
- page = requests.get(URL)
- soup = BeautifulSoup(page.content, 'html.parser')
- body = soup.find('div', {'class' : 'blogpostext'})
- H1=soup.h1.text.strip()
- out_file = open(Fn+H1+EX1, "w")
- out_file.write("\n"+H1)
- print(""+H1)
- out_file.write("\n"+body.text.strip())
- out_file.close()
- with open(Fn+H1+EX1, 'r') as inp:
- Pfile =open(H1+EX1, "w")
- for line in inp:
- if re.search('\S', line):
- Pfile.write(line)
- Pfile.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement