所以,我想要做的是制作一个脚本,它会自动将我的登录信息(我将在我的数据库中)添加到我想要的任何形式。DOM文档,编辑元素
为此,我从网站(使用cURL)获取html源代码,然后使用DOMdocument编辑输入的用户名和密码表单名称,然后输入此信息,然后单击登录
一切应该没问题吧?理论上是的,但事实并非如此。
这是做正确的代码:
$dom = new DOMdocument();
$dom->formatOutput = true;
@$dom->loadHTML(mb_convert_encoding($html, 'HTML-ENTITIES', $encoding));
$inputs = $dom->getElementsByTagName('input');
foreach ($inputs as $input)
{
if ($input->getAttribute('name') == $id_nameValue)
{
$new_input = $dom->createElement('input');
$new_input->setAttribute('name', $id_nameValue);
$new_input->setAttribute('value', $id_value);
$input->parentNode->replaceChild($new_input, $input);
}
if ($input->getAttribute('name') == $password_nameValue)
{
$new_input = $dom->createElement('input');
$new_input->setAttribute('name', $password_nameValue);
$new_input->setAttribute('value', $password_value);
$new_input->setAttribute('type', 'password');
$input->parentNode->replaceChild($new_input, $input);
}
}
echo $dom->savehtml();
我遇到的问题,与JavaScript不加载或CSS,或没有正确重定向...
让我们例如reddit的:https://ssl.reddit.com/login 他们有这样的CSS
<link rel="stylesheet" href="/static/reddit.cYdhnJIJSZ0.css" type="text/css" />
,而不必https://ssl.reddit.com/login/static/reddit.cYdhnJIJSZ0.css,所以我不能加载它正确LY,因为它使用了自己的网址一样
MY_URL.com/static/reddit.cYdhnJIJSZ0.css to find it...
这同样适用于JavaScript的,像
<script type="text/javascript" src="/static/jquery.js">
或用
<form id="login_login" method="post" action="/post/login" class="user-form login-form">
这将我重定向到MY_URL.com/post/login
我的问题是我该如何做这项工作? 如何编辑链接以包含网站网址? 由于这是我第一次使用DOM文档,我不知道我将如何去有关编辑形式,或脚本SRC ...
所以我的最终结果将是
<link rel="stylesheet" href="https://ssl.reddit.com/login/static/reddit.cYdhnJIJSZ0.css" type="text/css" />
<script type="text/javascript" src="https://ssl.reddit.com/login/static/jquery.js">
<form id="login_login" method="post" action="https://ssl.reddit.com/login/post/login" class="user-form login-form">
我是偏执狂还是会出现可疑?在任何情况下,您都不应该热链接来自其他网站的JavaScript,CSS或图像,以便自行放置。当然,你不应该设置一个看起来像一个网络钓鱼骗局。 – erisco
恩,哈哈?这是一个网络钓鱼骗局?我想这是个人使用,当我在一台不是我自己的计算机上,并且想要存储我想要登录的网站的用户名和密码时,所以我没有使用键盘记录或其他技巧来获取您的密码......并且它不是像即时通讯链接的CSS或JavaScript为我个人使用,它的网站从它...你甚至读过我说我想要它做什么? – alex2005
如果你想亲自看看它,可以在这里试试http://www.auto-complete.info/ ----用户名:user,密码:密码----只是不要在添加密码时使用真实密码新的页面,它的存储就像在db(现在)... – alex2005