Advertisement
Guest User

Carlos Crdenas Fernnde

a guest
Jan 11th, 2010
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.88 KB | None | 0 0
  1. import string
  2. import urllib2
  3. import os
  4. import sys
  5. import subprocess
  6.  
  7. def coma(cad):
  8.         try:
  9.             retcode = subprocess.call(cad, shell=True)
  10.             print retcode
  11.             if retcode < 0:
  12.                 print >>sys.stderr, "Proceso Hijo Fallo", -retcode
  13.             else:
  14.                 print >>sys.stderr, "Proceso Hijo enviado", retcode
  15.         except OSError, e:
  16.             print >>sys.stderr, "Ejecucion Fallida:", e
  17.  
  18. s0="http://www.tandf.co.uk/journals/JanMathMadness/"
  19. ur1="http://www.informaworld.com/smpp/"
  20. jur="JanMathMadness"
  21. coma("mkdir "+jur+" && cd "+jur+"/")
  22.  
  23. r0=urllib2.urlopen(s0)
  24. h0=r0.read()
  25.  
  26. for i in range(1,len(h0.split("<p class=\"crop\"><a href=\""))):
  27.     d=h0.split("<p class=\"crop\"><a href=\"")[i].split("\"><img")[0].split("\" title=\"")[0][-4:]
  28.     n=h0.split("<p class=\"crop\"><a href=\"")[i].split("\"><img")[0].split("\" title=\"")[1]
  29.     s1=h0.split("<p class=\"crop\"><a href=\"")[i].split("\"><img")[0].split("\" title=\"")[0]
  30.     coma("mkdir "+jur+"/"+d+" && cd "+jur+"/"+d+"/")   
  31.     coma("echo "+n+" > "+jur+"/"+d+"/Journal.txt")
  32.     r1=urllib2.urlopen(s1)
  33.     h1=r1.read()
  34.  
  35.     for j in range(1,len(h1.split("<td nowrap=\"nowrap\" style=\"text-indent: 5px;\">"))):
  36.         s2=ur1+h1.split("<td nowrap=\"nowrap\" style=\"text-indent: 5px;\">")[j][12:43]
  37.         coma("mkdir "+jur+"/"+d+"/"+str(j)+" && cd "+jur+"/"+d+"/"+str(j)+"/")     
  38.                 r2=urllib2.urlopen(s2)
  39.                 h2=r2.read()
  40.  
  41.         p=len(h2.split("title=\"Click to view the PDF fulltext\">Full Text PDF</a> | <a href=\"./"))-1
  42.  
  43.         for k in range(0,p):
  44.  
  45.             print ur1+h2.split("title=\"Click to view the PDF fulltext\">Full Text PDF</a> | <a href=\"./")[k][-58:-2]
  46.             coma("wget "+ur1+h2.split("title=\"Click to view the PDF fulltext\">Full Text PDF</a> | <a href=\"./")[k][-58:-2])
  47.             coma("mv *.pdf "+jur+"/"+d+"/"+str(j)+"/")         
  48.  
  49.         coma("cd .. ")
  50.  
  51.     coma ("cd .. ")
  52.  
  53. coma(" cd ..")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement