Last active
August 14, 2017 15:57
-
-
Save metr1ckzu/84ea71db28d172e236bc6b2ff833ee35 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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