Advertisement
karim0209

FinoU 7112020

Nov 7th, 2020
1,902
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.64 KB | None | 0 0
  1. #!/data/data/com.termux/files/usr/bin/python3
  2. # -*- coding: utf-8 -*-
  3. import requests
  4. from bs4 import BeautifulSoup
  5. import re
  6.  
  7. URL = input("Enter your Finalogy Article url name:")
  8. EX1 = ".txt"
  9. Fn = "NewFilename"
  10. page = requests.get(URL)
  11. soup = BeautifulSoup(page.content, 'html.parser')
  12. body = soup.find('div', {'class' : 'blogpostext'})
  13. H1=soup.h1.text.strip()
  14. out_file = open(Fn+H1+EX1, "w")
  15. out_file.write("\n"+H1)
  16. print(""+H1)
  17. out_file.write("\n"+body.text.strip())
  18. out_file.close()
  19. with open(Fn+H1+EX1, 'r') as inp:
  20.     Pfile =open(H1+EX1, "w")
  21.     for line in inp:
  22.         if re.search('\S', line):
  23.             Pfile.write(line)
  24.     Pfile.close()
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement