Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Youtube search without API Key.
- #Using Python 3.4.2
- #By Hardware@chatango.
- def yt(s):
- s = str(s).replace(" ", "+")
- link = "https://www.youtube.com/results?search_query="+s
- a = urlreq.urlopen(link)
- b = a.read().decode("UTF-8").strip()
- findUrls = re.findall('<a href="(.*?)" class="yt-uix-tile-link yt-ui-ellipsis yt-ui-ellipsis-2 yt-uix-sessionlink spf-link ', str(b))
- randomUrl = random.choice(findUrls)
- myUrl = "https://www.youtube.com"+randomUrl
- findData = urlreq.urlopen(myUrl)
- data = findData.read().decode("UTF-8")
- findTitle = re.search('<span id="eow-title" class="watch-title" dir="ltr" title="(.*?)">', str(data))
- return myUrl+"\r"+findTitle.group(1)
- print(yt("pokemon"))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement