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
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

80 рядки
1.8 KiB

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