瀏覽代碼

Reduction du nombre d'appel web nécéssaire

master
TheBidouilleur 2 週之前
父節點
當前提交
3c900b5f6b
共有 2 個文件被更改,包括 13 次插入6 次删除
  1. +6
    -2
      create_manga.py
  2. +7
    -4
      update_manga.py

+ 6
- 2
create_manga.py 查看文件

@@ -9,9 +9,9 @@ url = "https://mangadex.org/title/31477"

def check_if_exit(url):
id = get_id(url)
def create_manga(url):


def create_manga(url):
data = {"id" : get_id(url),
"title" : get_title(url),
"author" : get_author(url),
@@ -25,16 +25,20 @@ def create_manga(url):
print("Last chap" + str(data["chap"]))
cursor.execute(""" INSERT INTO manga(id, title, author, url, chap) VALUES(:id, :title, :author, :url, :chap)""", data)
conn.commit()

def main():
if len(sys.argv) == 2 :
print("Mode Script")
url = sys.argv[1]
print("URL : %s" % url)


else :
print("Mode utilisateur")
url = input("Veuillez entrer l'URL du manga : ")
print("URL : %s" % url)



if __name__ == '__main__':
main()

+ 7
- 4
update_manga.py 查看文件

@@ -6,7 +6,8 @@ conn = sqlite3.connect('database.db')
cursor = conn.cursor()

def main():
print("Pas de fonction Main")
#print("Pas de fonction Main")
update_manga(31477)

def update_manga(id):
url = get_url(id)
@@ -17,14 +18,16 @@ def update_manga(id):
rows = cursor.fetchall()
# Last_chapt est le dernier chapitre sauvegardé
last_chapt = str(rows[0][0])

new_chapt = get_last_chap(url)
print("Mise a jour de %s" % get_title(url))
print("Le dernier chapitre est %s" % last_chapt)
print("Le dernier chapitre enregistre est %s" % get_last_chap(url))
print("Le dernier chapitre sur mangadex est %s" % new_chapt)

if int(last_chapt) == int(get_last_chap(url)) :
if int(last_chapt) == int(new_chapt) :
print("Nous sommes a jour")
else :
print("Pas a jour ! Le dernier chapitre est %s " )
print("Pas a jour ! Le dernier chapitre est %s " % )
cursor.execute("UPDATE manga SET chap = '{}' WHERE id = '{}'".format(get_last_chap(url), get_id(url)))
conn.commit()



Loading…
取消
儲存