Reputation: 1807
I am trying to scrape this webpage: http://animeheaven.eu/watch.php?a=My%20Hero%20Academia%203&e=2
and download the video. As you can see it loads the 720p video. I can download the video from here. But I don't know how to get the other video version i.e. the 480p version from the drop-down menu. How do I select the 480p link?
Upvotes: 0
Views: 1392
Reputation: 9420
If you make a POST request with the parameter "rs" = "1" you get the data you want.
from bs4 import BeautifulSoup
import requests
link = "http://animeheaven.eu/watch.php?a=My%20Hero%20Academia%203&e=2"
html= requests.post(link, data = {'rs': '1'})
soup= BeautifulSoup(html.content,"lxml")
scripts= soup.findAll("script")
sc=scripts[4]
print (sc)
...
Outputs:
...
document.write("<a class='an' href='"+ pli +"'><div class='dl2'>Download 159 MB</div></a>");
...
Not:
...
document.write("<a class='an' href='"+ pli +"'><div class='dl2'>Download 255 MB</div></a>");
...
UPDATED in response to comment:
...
select = soup.find("select", {'name': 'rs'})
for option in select.find_all('option'):
print ("{} = {}".format(option.text, option['value']))
Outputs
720p = 0
480p = 1
Upvotes: 1