我正在尝试抓取以下网页:http://animeheaven.eu/watch.php?a=My%20Hero%20Academia%203&e=2
并下载视频。如您所见,它将加载720p视频。我可以从这里下载视频。但是我不知道如何从下拉菜单中获取其他视频版本,即480p版本。如何选择480p链接?
参考方案
如果使用参数“ rs” =“ 1”发出POST请求,则将获得所需的数据。
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)
...
输出:
...
document.write("<a class='an' href='"+ pli +"'><div class='dl2'>Download 159 MB</div></a>");
...
不:
...
document.write("<a class='an' href='"+ pli +"'><div class='dl2'>Download 255 MB</div></a>");
...
更新以回应评论:
...
select = soup.find("select", {'name': 'rs'})
for option in select.find_all('option'):
print ("{} = {}".format(option.text, option['value']))
产出
720p = 0
480p = 1
如果我得到url(''),我该如何使用另一个URL - javascript我是新手,正在写这篇文章,但是如果源上没有图像,那么我只有空白。有人可以告诉我,如果我正在获取背景图像,如何获取/images/no-image.jpg:url();这是我的代码:<div class="uk-clearfix uk-position-relative"> <div class="recipeb…
如何在没有for循环的情况下在Javascript中使用Django模板标签 - javascript我想在JavaScript中使用模板变量:我的问题是在javascript代码中使用for循环,for循环之间的所有事情都会重复..但我不想要....下面粘贴了我的代码..有人可以告诉我更好的方法吗这..因为这看起来很丑..这是我的代码: {% block extra_javascript %} <script src="/static/js…
使用JS和PHP更改弹出窗口背景图像 - javascript我有一个JS函数:function zoom(now) { document.getElementById("popup").style.display = "block"; document.getElementById("photos").style.backgroundImage = …
打印二维阵列 - javascript我正在尝试打印子元素。在this example之后。怎么做?。$myarray = array("DO"=>array('IDEAS','BRANDS','CREATIVE','CAMPAIGNS'), "JOCKEY"=>a…
获取JavaScript值到C#字符串 - javascript是否可以在C#中执行类似的操作?该值为“ 10/05/2014”string jsValue = javascript("$('#EstimatedStartDate').val()"); 参考方案 您能否更详细地阐明您要做什么。看来您正在尝试从javascript(客户…