求JS代码,点击网页上的那个播放按钮,谢谢!
https://www.5tps.vip/play/10255_46_1_133.html这样,我的Delphi热键调用,那个js,就能远程下一首播放了。 这个网页播放都没有加密。直接解析出远程播放地址。随便写几行代码,十分钟的事。 抓取页面的JS
播放:
document.querySelector("#jp_container_1 > div > div.jp-gui.jp-interface > ul.jp-controls > li:nth-child(2) > a").click();
暂停:
document.querySelector("#jp_container_1 > div > div.jp-gui.jp-interface > ul.jp-controls > li:nth-child(3) > a").click(); 解析出的mp3地址:
http://177x.wenwen120.com/ysts8.mp3 $(".jp-controls li a:eq(1)").click()
这个是播放
$(".jp-controls li a:eq(2)").click()
这个是暂停 document.querySelector('.jp-play').click() 本帖最后由 闷骚小贱男 于 2021-10-21 09:35 编辑
next(); 即可
----------
哦,不太对。他这个音频是在iframe框架 用webbrowser控件? 还是WebView2?
jauery
$("a#playup").click(); // 上一回
$("a.jp-play").click(); // 播放
$("a.jp-pause").click(); // 暂停
$("a#playnext").click(); // 下一回
$("a.jp-mute").click(); // 静音
$("a.jp-unmute").click(); // 取消静音
$("a.jp-volume-max").click(); // 最大音量 本帖最后由 冥界3大法王 于 2021-10-21 10:44 编辑
Jack2002 发表于 2021-10-21 10:04
用webbrowser控件? 还是WebView2?
jauery
javascript,true]$("a#playup").click(); //...
@Jack2002
用的是Delphi 11(即15)+JS Engine + Edge 控件(和你说的那个差不多((需要安装Microsoft Edge Dev))外加一个单独的WebView2Loader.dll
https://wwi.lanzoui.com/i9brYvl5agd(包括全部源码 和 编译后的EXE)
不知为啥,楼上这些位朋友的代码都报错呢,下面是部分源码:
procedure TFormMain.ButtonRunClick(Sender: TObject);
var
MyObject: JsValueRef;
Result: JsValueRef;
begin
if PageControl.ActivePage = TabSheetSimple then
with Engine do
try
MemoResultSimple.Clear;
MemoResultSimple.Text := ConvertToString(RunScript(MemoScriptSimple.Text))
except
on E: Exception do
ShowException(MemoResultSimple, E);
end
else if PageControl.ActivePage = TabSheetFunction then
with Engine do
try
MemoResultFunction.Clear;
MemoResultFunction.Text := ConvertToString(RunScript(MemoScriptFunction.Text))
except
on E: Exception do
ShowException(MemoResultFunction, E);
end
else if PageControl.ActivePage = TabSheetNativeFunction then
with Engine do
try
MemoResultNativeFunction.Clear;
RegisterFunction('NativeFunction');
MemoResultNativeFunction.Text := ConvertToString(RunScript(MemoScriptNativeFunction.Text));
except
on E: Exception do
ShowException(MemoResultNativeFunction, E);
end
else if PageControl.ActivePage = TabSheetNativeMethod then
with Engine do
try
MemoResultNativeMethod.Clear;
MyObject := CreateObject;
SetProperty(GlobalObject, 'MyObject', MyObject);
RegisterMethod(MyObject, 'NativeMethod');
MemoResultNativeMethod.Text := ConvertToString(RunScript(MemoScriptNativeMethod.Text))
except
on E: Exception do
ShowException(MemoResultNativeMethod, E);
end
else if PageControl.ActivePage = TabSheetVariable then
with Engine do
try
MemoResultVariable.Clear;
SetProperty(GlobalObject, 'MyVariable', CreateString('Hello'));
MemoResultVariable.Text := ConvertToString(RunScript(MemoScriptVariable.Text));
ShowMessage('MyVariable=' + ConvertToString(GetProperty(GlobalObject, 'MyVariable')));
except
on E: Exception do
ShowException(MemoResultVariable, E);
end
else if PageControl.ActivePage = TabSheetProperty then
with Engine do
try
MemoResultProperty.Clear;
MyObject := CreateObject;
SetProperty(GlobalObject, 'MyObject', MyObject);
SetProperty(MyObject, 'MyProperty', CreateString('Hello'));
MemoResultProperty.Text := ConvertToString(RunScript(MemoScriptProperty.Text));
ShowMessage('MyObject.MyProperty=' + ConvertToString(GetProperty(MyObject, 'MyProperty')));
except
on E: Exception do
ShowException(MemoResultProperty, E);
end
else if PageControl.ActivePage = TabSheetFunctionCall then
with Engine do
try
MemoResultFunctionCall.Clear;
RunScript(MemoScriptFunctionCall.Text);
Result := Call('hello', );
MemoResultFunctionCall.Text := ConvertToString(Result);
except
on E: Exception do
ShowException(MemoResultFunctionCall, E);
end
end;
$("#thisbody .jp-pause").click();//暂停
$("#thisbody .jp-play").click();//播放
页:
[1]
2