Skip to content

Instantly share code, notes, and snippets.

@metr1ckzu
Last active August 14, 2017 15:57
Show Gist options
  • Save metr1ckzu/84ea71db28d172e236bc6b2ff833ee35 to your computer and use it in GitHub Desktop.
Save metr1ckzu/84ea71db28d172e236bc6b2ff833ee35 to your computer and use it in GitHub Desktop.
from django.shortcuts import redirect, render, get_object_or_404
import requests
from bs4 import BeautifulSoup
def submit(request):
template_name = 'downloader/index.html'
result_template_name = 'downloader/saver_page.html'
if request.method == 'POST':
source = request.POST['source_url']
result_url = requests.get('http://www.youtubeinmp3.com/widget/button/?id={}'.format(source))
result_url.encoding = 'utf-8'
result_url_parsed = BeautifulSoup(result_url.text)
result_url_body = result_url_parsed.html.body
return render(request, result_template_name, {'result_url_body': result_url_body})
return render(request, template_name, {})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment