Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2016
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import os, sys
  2.  
  3. import urllib, re, cgi
  4. import HTMLParser, unicodedata
  5.  
  6. for URL in open('list.txt','r').readlines():
  7. #    print("URL =", URL)
  8.    
  9.     ## Parse playlist title
  10.     #
  11.     these_regex="<title>(.+?)</title>"
  12.     pattern=re.compile(these_regex)
  13.  
  14.     htmlfile=urllib.urlopen(URL)
  15.     htmltext=htmlfile.read()
  16.     title=re.findall(pattern,htmltext)
  17.  
  18.     title=HTMLParser.HTMLParser().unescape(title)[0]
  19.     print "Title = ", title.decode()
  20.  
  21. ----- RESULT --------
  22. Title =  Wizo - Anderster Full Album - YouTube
  23. Title =  Wizo - Bleib Tapfer / für&#39;n Arsch Full Album - YouTube
  24. Title =  WIZO - Uuaarrgh Full Album - YouTube
  25. Title =  WIZO - Full Album - &quot;Punk gibt&#39;s nicht umsonst! (Teill III)&quot; - YouTube
  26. Title =  WIZO - Full Album - &quot;DER&quot; - YouTube
  27. Title =  Alarmsignal -  Wir leben - YouTube
  28. Title =  the Pogues - Body of an american - YouTube
  29. Title =  The Pogues -  The band played waltzing matilda - YouTube
  30. Title =  Hey Rote Zora - Heiter bis Wolkig - YouTube
  31. Title =  Für immer Punk - die goldenen Zitronen - YouTube
  32. Title =  Fuckin&#39; Faces - Krieg und Frieden - YouTube
  33. Title =  Sluts - Anders - YouTube
  34. Title =  Absturz - Es ist schön ein Punk zu sein - YouTube
  35. Title =  Broilers - Ruby Light &amp; Dark - YouTube
  36. Title =  Less Than Jake 02 - My Very Own Flag - YouTube
  37. Title =  The Mighty Mighty Bosstones - The Impression That I Get - YouTube
  38. Title =  Streetlight Manifesto - Failing Flailing (lyrics) - YouTube
  39. Title =  Mustard Plug - Mr. Smiley - YouTube
  40.  
  41. But when i try:
  42. os.mkdir(title)
  43.  
  44. i get the following:
  45. UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 23: ordinal not in range(128)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement