forked from GauravSingh9356/J.A.R.V.I.S
-
Notifications
You must be signed in to change notification settings - Fork 0
/
youtube.py
26 lines (21 loc) · 819 Bytes
/
youtube.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from urllib.request import urlopen
import urllib.parse
import re
from bs4 import BeautifulSoup
import webbrowser
chrome_path = 'C:\Program Files (x86)\Google\Chrome\Application\chrome.exe'
webbrowser.register(
'chrome', None, webbrowser.BackgroundBrowser(chrome_path))
def you(textToSearch):
query = urllib.parse.quote(textToSearch)
url = "https://www.youtube.com/results?search_query=" + query
webbrowser.get('chrome').open_new_tab(url)
#response = urlopen(url)
#html = response.read()
#soup = BeautifulSoup(html, "lxml")
#flag = 0
#search_results=re.findall('href=\"\\/watch\\?v=(.{11})', html.decode())
#print(search_results)
#webbrowser.get('chrome').open_new_tab('http://youtube.com/watch?v=' + search_results[0])
if __name__ == '__main__':
you('any text')