コード例 #1
0
ファイル: scrape.py プロジェクト: process/mu-scrape
  else:
    album_id = res[0]

  cur.execute("insert or ignore into artists (name) values (?)", (artist,))
  cur.execute("insert or ignore into links (url, album_id) values (?,?)", (link, album_id))
  #cur.execute("insert or ignore into samples (url, album_id) values (?,?)", (sample, album_id))
  db.commit()
  cur.close()
  ##
  if isDebug:
    print "Link:", link
    print "Artist:", artist
    print "Album:", album
    print "Desc:", desc
    print "Year:",year
    print "Sample:", sample
    print
    

threads = chanscrape.getAllThreads("mu")
for thread in threads:
  for post in thread['posts']:
    parsePost(post)

util.webPrint("""<!doctype html>
<html>
<body>Scrape complete</body>
</html>
""")

コード例 #2
0
ファイル: search.py プロジェクト: process/mu-scrape
print """<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>/mu/scrape</title>
<link rel="stylesheet" type="text/css" href="/static/style.css">
</head>
<body>
"""

form = cgi.FieldStorage()
# Warning: we assume that the above code will run without error

try:
   form["q"] # Will raise KeyError if "q" does not exist
   util.webPrint("<h1>Showing results for \"<i>%s</i>\":</h1><br />" % form["q"].value)
   db = sqlite3.connect("muscrape.db")
   c = db.cursor()
   resultCount = 0
   for row in c.execute("select * from albums where album_name like ?", ('%' + form["q"].value + '%',)):
      util.webPrint("%s - %s" % (row[1], row[2]))
      if row[3] != None:
         util.webPrint("(%s)" % row[3])
      util.webPrint("<br />")
      util.webPrint('<a href="' + list(c.execute("select url from links where album_id=?", unicode(row[0])))[0][0] + '">Download</a> || <a href="/music/%s/%s/">Info</a><!--[User_Rating goes here]--><br />' % (cgi.escape(row[1], True), cgi.escape(row[2], True)))
      util.webPrint("<br />")
      resultCount += 1
   if resultCount == 0:
      print "<i>Sorry. No results were found.</i><br />"
   c.close()
   
コード例 #3
0
ファイル: album.py プロジェクト: process/mu-scrape
for link in cur.execute("select url from links where album_id=?", unicode(albumData[0])):
    links.append(link[0])

samples = []
for sample in cur.execute("select url from samples where album_id=?", unicode(albumData[0])):
    samples.append(sample[0])

# TODO: Fill in the data
print "Content-Type: text/html"
print

util.webPrint(
    """<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" type="text/css" href="/static/style.css">
<title>%s - %s</title>
</head>
<body>
%s - %s <br />
Year: %s <br />
Description: %s <br />
Samples: %s <br />
Download links: %s <br />
</body>
</html>
"""
    % (artist, album, artist, album, year, desc, samples, links)
)