2
0

mark.py 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. from set_mark.namu import namu
  2. import re
  3. import html
  4. import sqlite3
  5. from urllib import parse
  6. import time
  7. import threading
  8. def load_conn2(data):
  9. global conn
  10. global curs
  11. conn = data
  12. curs = conn.cursor()
  13. def send_parser(data):
  14. if not re.search('^<br>$', data):
  15. data = html.escape(data)
  16. javascript = re.compile('javascript:', re.I)
  17. data = javascript.sub('', data)
  18. data = re.sub('&lt;a href=&quot;(?:(?:(?!&quot;).)*)&quot;&gt;(?P<in>(?:(?!&lt;).)*)&lt;\/a&gt;', '<a href="' + parse.quote('\g<in>').replace('/','%2F') + '">\g<in></a>', data)
  19. return data
  20. def plusing(name, link, backtype):
  21. curs.execute("select title from back where title = ? and link = ? and type = ?", [link, name, backtype])
  22. if not curs.fetchall():
  23. curs.execute("insert into back (title, link, type) values (?, ?, ?)", [link, name, backtype])
  24. def namumark(title = '', data = '', num = 0):
  25. data = namu(conn, data, title)
  26. if num == 1:
  27. i = 0
  28. while 1:
  29. try:
  30. _ = data[2][i][0]
  31. except:
  32. break
  33. thread_start = threading.Thread(target = plusing, args = [data[2][i][0], data[2][i][1], data[2][i][2]])
  34. thread_start.start()
  35. thread_start.join()
  36. i += 1
  37. conn.commit()
  38. return data[0] + data[1]