Reputation: 349
I am trying to get the name of TV Show (Episode/Season)/Movie from the Netflix URL. Is there a way of doing it using requests
and urllib
? I guess I'll need the API key and secret for that.
This is what I'm trying to do.
e.g. I have this URL for Z Nation.
url = "https://www.netflix.com/gb/title/80008434"
url_data = urlparse.urlparse(url)
query = urlparse.parse_qs(url_data.query)
id = query["v"][0]
id should give me 80008434
netflixurl = ''
r = requests.get(netflixurl)
js = r.json()
item = js[""]
item should give me Z Nation Season 3. (Or whatever season/episode url is url)
Using the pyflix2
API for 'NetflixAPIV2'.
How should I go about this? Please help!
EDIT: I use this for youtube. Is there a similar thing for netflix?
import lxml
from lxml import etree
import urllib
youtube = etree.HTML(urllib.urlopen("https://www.youtube.com/watch?v=L93-7vRfxNs").read())
video_title = youtube.xpath("//span[@id='eow-title']/@title")
song = ''.join(video_title)
Result : Daft Punk - Aerodynamic
Upvotes: 1
Views: 7463
Reputation: 1
so I wrote some code for this exact thing as a lot of websites gave for the USA or other regions and couldn't translate to the exact answer that worked for my Netflix.
This one uses selenium but it shouldn't be hard to downloads and understand the code that I wrote.
https://github.com/Eglis05/netflix-selenium
You can have a look at it and report anything you don't like. :)
Upvotes: 0
Reputation: 1
There is an API that you can subscribe to developed by uNoGS. The downside is that you can have a free account but have to submit your credit card details as, if you go over 100 requests a month, you will be charged. Needless to say alarm bells rang. Therefore, I'm looking into building my own and in the very early stages. Having seen some of the replies I just thought I'd throw it out there that the robots.txt file shows that the /browse subdirectory shows as 'allowed'. Normally on websites such as this, they stipulate that they allow it for reputable search engines to be able to scrape. There is however no such clause and therefore, with the legality, as discussed so far, it appears that scraping the browse section is both legal and ethical. That being said, even there is no 'Crawl-delay' stipulated, ethically I would suggest putting one if you do succeed in getting a requests working.
Upvotes: 0
Reputation: 584
Sadly, Netflix has discontinued the use of its public API and is not accepting any new developers.
You can look into Netflix Roulette API, which is an unofficial API and lets you run queries on Netflix. You can use that API in conjunction with urllib
or requests
and get the results that you need.
Apart from that you can use general webscraping, using BeautifulSoup and requests. But doing it this way is not recommended as it will consume immense amount of bandwidth to scrape all the directories.
Upvotes: 1