【发布时间】:2011-10-19 05:57:58
【问题描述】:
所以,我想做的是制作一个脚本,它会自动将我的登录信息(我将在我的数据库中)添加到我想要的任何形式。
为此,我从网站(使用 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,所以我无法正确加载它,因为它使用我的网址,如
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
我的问题是我怎样才能做到这一点? 如何编辑链接以包含网站 url? 由于这是我第一次使用 DOMdocument,我不知道如何编辑表单或脚本 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 或图像热链接到您自己的位置。绝对不应该设置看起来像网络钓鱼诈骗的东西。
-
呃,哈哈?这是一个网络钓鱼诈骗吗?我想要这个供个人使用,当我在不是我自己的计算机上时,并且想要存储我想要登录的网站的用户名和密码,所以我不会通过键盘记录或其他技巧来获取你的密码......它不是就像我为我个人使用链接 css 或 javascript 一样,它的网站来自......你甚至读过我说我想要它做什么吗?
-
如果您想自己查看,请在此处尝试auto-complete.info ---- 用户名:用户,密码:密码 ---- 添加新页面时不要使用真实密码,它的存储就像在数据库中(现在)......
-
为什么不直接使用浏览器的表单补全?
-
因为当我在网吧或大学计算机时,我真的无法使用该功能,不是吗?我希望更多的人试图帮助我而不是质疑我的小项目......
标签: php html domdocument