kilya

Get specific data in Python

Mar 15th, 2019
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. # import Regex
  2. import re
  3.  
  4. # open the file and read
  5. f = open("recaptcha__fr.js", "r")
  6. content = f.read()
  7.  
  8. # Start Conversion : special character to letter
  9. c1 = re.sub("\\\\u00e9", "é", content)
  10. c2 = re.sub("\\\\u00ea", "ê", c1)
  11. c3 = re.sub("\\\\u00ee", "î", c2)
  12. c4 = re.sub("\\\\u00e8", "è", c3)
  13. c5 = re.sub("\\\\u00f4", "ô", c4)
  14. c6 = re.sub("\\\\u00e0", "à", c5)
  15. # End Conversion
  16.  
  17. # get specific text in <strong> ... </strong>
  18. getStrong = re.findall(r'(?<=<strong>)[\w\s\\\'""\(\)+\.]+(?=</strong>)', c6)
  19.  
  20. print(getStrong)
  21.  
  22. # convert list to string with newline
  23. text = '\n'.join(getStrong)
  24. # create a text file and append data
  25. creat = open("creat.txt", "w+")
  26.  
  27. #-------
  28. creat.write(text)
  29. #-------
Add Comment
Please, Sign In to add comment