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
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

91 linhas
2.2 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_status(url):
  31. fp = urllib.request.urlopen(url)
  32. mybytes = fp.read()
  33. html = mybytes.decode("utf8")
  34. fp.close()
  35. soup = BeautifulSoup(html, "html5lib")
  36. status = soup.find_all("div", class_="row m-0 py-1 px-0 border-top")
  37. print(str(status))
  38. def get_id(url):
  39. id = url.split('/')[4]
  40. return id
  41. def get_url(id):
  42. id_url = "https://mangadex.org/title/%s" % id
  43. return id_url
  44. def get_last_chap(url):
  45. fp = urllib.request.urlopen(url)
  46. mybytes = fp.read()
  47. html = mybytes.decode("utf8")
  48. fp.close()
  49. soup = BeautifulSoup(html, "html5lib")
  50. chap = soup.find('a', {'class' : 'text-truncate'})
  51. chap = str(chap).split('Ch. ')
  52. chap = chap[1][:-4]
  53. chap = [int(s) for s in chap.split() if s.isdigit()]
  54. return chap[0]
  55. def main():
  56. url = "https://mangadex.org/title/31477"
  57. # title = get_title(url)
  58. # print("Titre de l'anime : %s " % title)
  59. # author = get_author(url)
  60. # print("Auteur de l'anime : %s " % author)
  61. # id = get_id(url)
  62. # print("ID Mangadex : %s " % id)
  63. # chap = get_last_chap(url)
  64. # print("Dernier chap : %s " % chap)
  65. # link = get_url(get_id(url))
  66. # print("Url mangadex : %s" % link)
  67. # img = get_img(url)
  68. # print("Image : %s" % img)
  69. status = get_status(url)
  70. print("Status : %s" % status)
  71. if __name__ == '__main__':
  72. main()