我想抓取网页并提取嵌入在网页中的视频网址。我首先使用了Inspect
工具,可以很容易地看到嵌入式链接,如下图所示:
还有目标<video>
标签:
<video class="jw-video jw-reset" tabindex="-1" disableremoteplayback="" webkit-playsinline="" playsinline="" preload="metadata" src="https://lh3.googleusercontent.com/YYxKbKt3Apa8A2LkHKBJ7Fx6GU_iCIjEeGyyPJm_Ll-9hO4K8fDZV1pAbYprwpRhS5yFanf7=m18?title=[CayPhim.Net]-Bay-Vien-Ngoc-Rong-Sieu-Cap-tap-6.[360p]"></video>
然后我尝试使用View Page Source
工具并搜索了链接,但找不到它。相反,我发现了一些javascript
代码,这些代码似乎用于动态地(在页面加载时)将链接添加到页面并添加到页面:
<div id="switchserver" style="height:100%;">
<div id="phim_html5" style="height:100%;">
<div class="loading"></div>
</div>
<script>$(document).ready(function () {
$.ajax({
url: "http://player.cayphim.net/jwplayer7/index_googima.php",
type: "GET",
cache: false,
data: {
"url": "8ce46ffa35805780571877c8ae5808f6a5e8898ebf9d294326735716694ccb4279505da51df9678cc8601a390a422d5e639449ec90332ee518e06f1dd579606d106f292d49bb38d9b2e80d0ee965a5c0e2911922e48ac972c521c4236512d356681404472b2cb39d9fff915bb4da21c8315d3fd6fc6cb0d2ed27183598661d40",
"name": "QmF5IFZpZW4gTmdvYyBSb25nIFNpZXUgQ2FwIHRhcCA2",
"sub": ""
},
success: function (msg) {
$("#phim_html5").html(msg);
}, error: function () {
$("#phim_html5").html("<div class='player-error'>Server quá tải. Vui lòng chọn server khác bên dưới...</div>");
},
});
});
</script>
<img style="display: none" src="http://image.cayphim.net/1553256337-lSC0nSX6Wj9dlOXfK29gK2iwoKF9D0p4YwnxYgmyCwmyBfJ29eW1wKpPetD3BkBKF9D0p4MsZPPjEReTD0UVY0K4YvoGKF9D0p42wODHaQKFo5pGMVmG9XmN05lP80DksxCQaHXKF9D0p4MMJwwhnyohFxsEYKF9D0p4wRJH5xYk1eXEr9mETjpng" />
</div>
现在,我使用Advanced REST Client
向GET
发出了http://player.cayphim.net/jwplayer7/index_googima.php
代码中指定的参数,对javascript
发出了<div id="playerjw7">Trình duyệt của bạn không hỗ trợ xem phim bằng Player HTML5. Vui lòng cài đặt Chrome hoặc Firefox</div>
请求,但是我收到了包含以下内容的响应:>
var connString = "mongodb+srv";
var client = new MongoClient(connString);
var database = client.GetDatabase("Base");
var collection = database.GetCollection<UsuariosAcessos>("collection"); //Here you put you Model
var filter = Builders<UsuariosAcessos>.Filter.Eq(x => x.PartnerId, cliente)
& Builders<UsuariosAcessos>.Filter.Eq(x => x.CD_CLIENTE, codCond);
var lista = collection.Aggregate().Match(filter).Project(x => new UsuariosAcessos
{
CD_CLIENTE = x.CD_CLIENTE,
ID_ACESSO = x.ID_ACESSO,
CD_ACESSO = x.CD_ACESSO,
NOME = x.NOME,
NU_TELEFONE = x.NU_TELEFONE,
EMAIL = x.EMAIL,
NU_KIPER_RF = x.NU_KIPER_RF,
NU_KIPER_TAG = x.NU_KIPER_TAG,
FG_KIPER_MOBILE = x.FG_KIPER_MOBILE,
KEY_HASH = x.KEY_HASH
}).ToList();
是的,它是越南语,但这表示“您的浏览器不支持Video Player HTML5。请安装Chrome或Firefox”。
我如何以编程方式抓取并提取嵌入的视频网址?