Skip to content

Instantly share code, notes, and snippets.

@eduzen
Created February 5, 2022 20:09
Show Gist options
  • Save eduzen/406c02aa1aba0e38668d2d07f6c9f3cb to your computer and use it in GitHub Desktop.
Save eduzen/406c02aa1aba0e38668d2d07f6c9f3cb to your computer and use it in GitHub Desktop.
busqueda de pelis en yify
import requests
from flask import Flask
from flask import request
app = Flask(__name__)
@app.route("/")
def hello_world():
return "<p>Hello, World!</p>"
@app.route("/pelis")
def hello_pelis():
return "<p>Hello, pelis!</p>"
@app.route("/buscar/", methods=["GET", "POST"])
def hello_buscar():
if request.method == "GET":
formulario = """
<h1> Busqueda </h1>
<form method="post">
<input type="text" name="busqueda">
<input type="submit" value="enviar">
</form>
"""
return formulario
else:
pelicula = request.form['busqueda']
yify = f"https://yts.mx/api/v2/list_movies.json?query_term={pelicula}"
respuesta = requests.get(yify)
respuesta_json = respuesta.json()
data = respuesta_json["data"]
print(type(data))
html = ""
for movie in data['movies']:
html = html + f"<p>{movie['title']}</p>"
for torrent in movie['torrents']:
url = torrent["url"]
html = html + f"<a href='{url}'>link</a><br>"
return f"Estoy en un POST y queres buscar: <b>{html}</b>"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment