Advertisement
icantrank

Url requests in python v420

Mar 21st, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.76 KB | None | 0 0
  1. import re;
  2.  
  3. import urllib2;
  4. string = urllib2.urlopen("https://pastebin.com/raw/LWcg4RRq").read();
  5.  
  6. # only title that comes right after movie
  7. titleRe = re.compile('type="movie".*\stitle="([^"]+)"', re.M);
  8.  
  9.  
  10. # only key which comes after <part
  11. keyRe = re.compile('<Part.*\skey="([^"]+)"', re.M);
  12.  
  13. # only thumb which comes after movie
  14. thumbRe = re.compile('type="movie".*\sthumb="([^"]+)"', re.M);
  15. titles = re.findall(titleRe, string);
  16. keys = re.findall(keyRe, string);
  17. thumb = re.findall(thumbRe, string);
  18. i=0;
  19.  
  20. for title in titles:
  21.         print "<item>";
  22.         print "<title>" + title + "</title>";
  23.         print "<link>" + keys[i] + "</link>";
  24.         print "<thumbnail>" + thumb[i] + "</thumbnail>";        
  25.         print "</item>\r\n";
  26.         i=i+1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement