現在、Python を使用して Foscam 8910W IP カメラからビデオを録画しようとしています。
私は次のようなスレッドに相談することから始めました。
IPカメラからmjpeg httpストリームを解析するには?
最初のいくつかのコマンドを実行しました
その後、カメラの IP にはユーザー名とパスワードが必要なため、その障害を克服する必要があることに気付きました。だから私はツイルをインストールし、ツイルコマンドを使用してログインしようとしています:
インストールされたツイルを使用して Web サイトにログインする方法は?
そのスレッドを使用して、ツイル シェルにログインしました。次に、このページからいくつかのコマンドを試しました。
そのような
go("http://<camera's IP address>")
その後
show_forms()
その時点で、次のような応答が返されます
<generator object __call__ at 0x106198780>
ページのソース コードに Cookie が記載されていることに気付いたので、試してみました。
show_cookies
そして、私は同様の応答を得ました
<function show_cookies at 0x106026488>
そこからどこへ行けばいいのかわからない。私もこのスレッドを真似てみました:
Python で Web サイトにログインするにはどうすればよいですか?
私の IP cam ログイン ページのソース コードに、「login_user」変数と「login_pwd」変数が記載されていることに気付きました。
from twill.commands import *
go('http://mysite.org')
fv("1", "email-email", "blabla.com")
fv("1", "password-clear", "testpass")
submit('0')
fv("1", "login_user", "<my_user_name>")たとえば、使用しました。エラーが発生しました:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/Library/Python/2.7/site-packages/twill-0.9-py2.7.egg/twill/commands.py", line 433, in formvalue
raise TwillAssertionError("no matching forms!")
twill.errors.TwillAssertionError: no matching forms!
何か案は???
ログインしようとしているページのコードは次のとおりです。
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="style.css" type="text/css">
<title></title>
<style>
BODY {
MARGIN: 0px; BACKGROUND-COLOR: #969696; font: arial;
}
</style>
<script src="jquery-1.4.4.min.js"></script>
<script src="public.js"></script>
<script language = "javascript">
function OK()
{
top.user = document.getElementById("login_user").value;
top.pwd = document.getElementById("login_pwd").value;
top.$.getScript("check_user2.cgi?user="+encodeURIComponent(top.user)+'&pwd='+encodeURIComponent(top.pwd), function()
{
if(top.pri == 0) {
alert(top.str_ftp_error_user);
}
else
{
if ("" == top.pwd)
{
alert(top.str_pwd_note);
}
top.setcookie('login_user',top.user,720);
//top.setcookie('login_pwd',top.pwd,720);
location='login.htm';
}
})
}
function set_language(value)
{
if(value==0)
{
language='english';
}
else if(value==1)
{
language='Deutsch';
}
else if(value==2)
{
language='french';
}
else if(value==3)
{
language='Italian';
}
else if(value==4)
{
language='spanish';
}
else if(value==5)
{
language='Netherlands';
}
else if(value==6)
{
language='Polski';
}
else if(value==7)
{
language='Hungarian';
}
else if(value==8)
{
language='simple_chinese';
}
else if(value==9)
{
language='traditional_chinese';
}
else if(value==10)
{
language='Portugal';
}
else if(value==11)
{
language='Czech';
}
else if(value==12)
{
language='Turkish';
}
else if(value==13)
{
language='Russian';
}
else if(value==14)
{
language='Korean';
}
else if(value==15)
{
language='Indonesian';
}
else if(value==16)
{
language='Denmark';
}
else
{
language='english';
}
top.setcookie('language',language,720);
top.location.reload();//reload index.html
}
function get_language()
{
var lang_ret=0;
var tmp_lang=top.getcookie('language');
if(tmp_lang=='')
{
lang_ret=0;
}
else
{
if(tmp_lang=='english')
{
lang_ret=0;
}
else if(tmp_lang=='Deutsch')
{
lang_ret=1;
}
else if(tmp_lang=='french')
{
lang_ret=2;
}
else if(tmp_lang=='Italian')
{
lang_ret=3;
}
else if(tmp_lang=='spanish')
{
lang_ret=4;
}
else if(tmp_lang=='Netherlands')
{
lang_ret=5;
}
else if(tmp_lang=='Polski')
{
lang_ret=6;
}
else if(tmp_lang=='Hungarian')
{
lang_ret=7;
}
else if(tmp_lang=='simple_chinese')
{
lang_ret=8;
}
else if(tmp_lang=='traditional_chinese')
{
lang_ret=9;
}
else if(tmp_lang=='Portugal')
{
lang_ret=10;
}
else if(tmp_lang=='Czech')
{
lang_ret=11;
}
else if(tmp_lang=='Turkish')
{
lang_ret=12;
}
else if(tmp_lang=='Russian')
{
lang_ret=13;
}
else if(tmp_lang=='Korean')
{
lang_ret=14;
}
else if(tmp_lang=='Indonesian')
{
lang_ret=15;
}
else if(tmp_lang=='Denmark')
{
lang_ret=16;
}
}
return lang_ret;
}
function get_user()
{
var tmp_user = top.getcookie('login_user');
return tmp_user;
}
function get_pwd()
{
var tmp_pwd = top.getcookie('login_pwd');
return tmp_pwd;
}
function body_onload()
{
var lang_type=get_language();
document.getElementById("select_Language").value=lang_type;
//var pwd_type = get_pwd();
//document.getElementById("login_pwd").value = pwd_type;
var user_type = get_user();
document.getElementById("login_user").value = user_type;
}
$(function(){
$("#login_user").select().focus();
$("#login_user, #login_pwd, #login_botton, #select_Language").keydown(function(e){
if (e.keyCode == 13){
OK();
}
});
})
</script>
</head>
<body onLoad="body_onload()">
<div style="width:100%; height:50px;"></div>
<table border=0 cellpadding=0 cellspacing=0 width=400 height=250 align="center" style="font-family:Arial; background:url(images/loginbg1.gif) no-repeat">
<tr height = 60>
<td colspan="3">
<div > <font style="font: arial; "><strong><script>document.write(top.str_language_select);</script></strong></font>
<select name="select" id="select_Language" onChange="set_language(value)" >
<option value="0">English</option>
<option value="1">Deutsch</option>
<option value="2">Française</option>
<option value="4">España</option>
<option value="3">Italiano</option>
<option value="10">Portugal</option>
<option value="13">Pусский</option>
<option value="5">Nederland</option>
<option value="6">Polska</option>
<option value="7">Hungarian</option>
<option value="12">Türk</option>
<option value="11">Češka</option>
<option value="16">Dansk</option>
<option value="14">한국의</option>
<option value="15">Indonesia</option>
<option value="8">简体中文</option>
<option value="9">繁体中文</option>
</select>
</div>
</td>
<td></td>
<td> </td>
</tr>
<tr>
<td colspan="2"> </td>
<td height="10" valign=top align=right></td>
<td> </td>
</tr>
<tr align="center" height="40">
<td style=" float:right; line-height:40px;" colspan="2"><font style="font: arial;"><strong><script>document.write(top.str_user);</script></strong></font>
</td>
<td align="right"><div><input id="login_user" style="width: 146px; height: 23px;"/></div></td>
<td> </td>
</tr>
<tr align="center" height="40">
<td style="float:right; line-height:40px;" colspan="2"><font style="font: arial;"><strong><script>document.write(top.str_pwd);</script></strong></font>
</td>
<td align="right"><div><input id="login_pwd" type="password" style="width: 146px; height: 23px;"/></div></td>
<td> </td>
</tr>
<tr align="center" height = 70>
<td style="width:180px; float:right;" colspan="2"></td>
<td ><div id="login_botton" onClick="javascript:OK();" style="background:url('images/loginbutton1.png') no-repeat;width:100px;height:25px;cursor:pointer;line-height:25px; float:center;" ><font align="center" style="font: arial;"><strong><script>document.write(top.str_index_ok);</script></strong></font></div>
</td>
<td> </td>
</tr>
</table>
</body>
わかりました、少し進歩しました。show forms()コマンドが出力を生成しなかった理由は、最初にアクセスした Web アドレス. ソース コードを確認すると、ブラウザのアドレスが /login_user.htm に変更されていることに気付きました。を使用するgo('http://000.00.000.00/login_user.htm')と、'showforms()'探していた出力が得られました。
## ## __Name__________________ __Type___ __ID________ __Value__________________
1 select select select_L ... ['0'] of ['0', '1', '2', '4', '3', ' ...
2 None text login_user
3 None password login_pwd
送信ボタンに問題があり、まだ問題がありましたが、今は機能していまし fv('1','login_user', '<username>')た。fv('1','login_pwd', '<password>')
それについて何か考えはありますか?