Un serveur permettant de récupérer à quelle manga on s'est arrêté d'une licence. Un script se chargera de récupérer automatiquement les derniers mangas à jour à l'aide du site MangaDex
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

66 rindas
1.5 KiB

  1. import urllib.request
  2. from bs4 import BeautifulSoup
  3. url = "https://mangadex.org/title/31477"
  4. def get_title(url):
  5. fp = urllib.request.urlopen(url)
  6. mybytes = fp.read()
  7. html = mybytes.decode("utf8")
  8. fp.close()
  9. soup = BeautifulSoup(html, "html5lib")
  10. for code in soup.find('title'):
  11. title = code
  12. title = title[:-18]
  13. return title
  14. def get_author(url):
  15. fp = urllib.request.urlopen(url)
  16. mybytes = fp.read()
  17. html = mybytes.decode("utf8")
  18. fp.close()
  19. soup = BeautifulSoup(html, "html5lib")
  20. dict = soup.find('a', {'title' : 'Other manga by this author'})
  21. author = str(dict).split('"')[4][1:][:-4]
  22. return author
  23. def get_id(url):
  24. id = url.split('/')[4]
  25. return id
  26. def get_url(id):
  27. id_url = "https://mangadex.org/title/%s" % id
  28. return id_url
  29. def get_last_chap(url):
  30. fp = urllib.request.urlopen(url)
  31. mybytes = fp.read()
  32. html = mybytes.decode("utf8")
  33. fp.close()
  34. soup = BeautifulSoup(html, "html5lib")
  35. chap = soup.find('a', {'class' : 'text-truncate'})
  36. chap = str(chap).split('Ch. ')
  37. chap = chap[1][:-4]
  38. chap = [int(s) for s in chap.split() if s.isdigit()]
  39. return chap[0]
  40. def main():
  41. title = get_title(url)
  42. print("Titre de l'anime : %s " % title)
  43. author = get_author(url)
  44. print("Auteur de l'anime : %s " % author)
  45. id = get_id(url)
  46. print("ID Mangadex : %s " % id)
  47. chap = get_last_chap(url)
  48. print("Dernier chap : %s " % chap)
  49. link = get_url(get_id(url))
  50. print("Url mangadex : %s" % link)
  51. if __name__ == '__main__':
  52. main()