本篇文章给大家谈谈discuz模拟登录,以及discuz注册页面对应的知识点,希望对各位有所帮助,不要忘了收藏本站喔。
本文目录一览:
- 1、如何用Java实现模拟登录Discuz!论坛并下载返回的html代码?
- 2、DISCUZ!论坛中能否不经过前台登陆页面,直接从后台登陆
- 3、php的模拟登录求助大神
- 4、discuz怎么在电脑模拟手机
- 5、discuz 3.2 怎么实现登录页面?
- 6、如何在第三方模拟登陆discuz,模拟发帖
1、如何用Java实现模拟登录Discuz!论坛并下载返回的html代码?
package org.shaw;
import org.apache.commons.httpclient.Cookie;
import org.apache.commons.httpclient.HttpClient;
import org.apache.commons.httpclient.NameValuePair;
import org.apache.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.PostMethod;
public class BaiyouBBS {
static final String LOGON_SITE = "";
static final int LOGON_PORT = 80;
public Cookie[] login(String name, String pas) {
try {
HttpClient client = new HttpClient();
client.getHostConfiguration().setHost(LOGON_SITE, LOGON_PORT);
PostMethod post = new PostMethod("/logging.php?action=login");
client.executeMethod(post);
String responseString = new String(post.getResponseBody(), "gbk");
post.releaseConnection();
String formhash = getFormHash(responseString);
System.out.println(formhash);
post = new PostMethod("/logging.php?action=login");
NameValuePair[] params = new NameValuePair[11];
params[0] = new NameValuePair("loginfield", "username");
params[1] = new NameValuePair("username", name);
params[2] = new NameValuePair("password", pas);
params[3] = new NameValuePair("referer", "index.php");
params[4] = new NameValuePair("questionid", "0");
params[5] = new NameValuePair("answer", "");
params[6] = new NameValuePair("cookietime", "2592000");
params[7] = new NameValuePair("formhash", formhash);
params[8] = new NameValuePair("loginmode", "");
params[9] = new NameValuePair("loginsubmit", "true");
params[10] = new NameValuePair("styleid", "");
post.setRequestBody(params);
client.executeMethod(post);
// responseString = new String(post.getResponseBody(), "gbk");
post.releaseConnection();
GetMethod get = new GetMethod("/index.php");
client.executeMethod(get);
responseString = new String(get.getResponseBody(), "gbk");
get.releaseConnection();
System.out.println(responseString);
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public String getFormHash(String htmlContent) {
try {
int start = htmlContent.indexOf("name=\"formhash\"");
start = htmlContent.indexOf("value=\"", start) + 7;
int end = htmlContent.indexOf("\"", start);
String formhash = htmlContent.substring(start, end);
return formhash;
} catch (RuntimeException e) {
throw e;
}
}
public static void main(String[] args) {
new BaiyouBBS().login("zzzxxxzzz", "zzzxxxzzz");
}
}
2、DISCUZ!论坛中能否不经过前台登陆页面,直接从后台登陆
那估计只能用第二种方案了,不知道jsp里类似C#的WebRequest的东东是什么,
总之就是模拟提交web登录的方案了
当然可行,有2个方案:
1、修改你公司的系统,根据DISCUZ论坛登录后的信息,设置这些信息(无非是Session或Cookie之类的信息),并把论坛和你的系统放在同一个虚拟目录下
2、如果是单独的2个系统,可以在你公司系统里登录成功的时候,用WebRequest同时登录到论坛
3、php的模拟登录求助大神
?php
02 !extension_loaded('curl') die('The curl extension is not loaded.');
03
04 $discuz_url = '论坛地址
05 $login_url = $discuz_url .'/do.php?ac=login';//登录页地址
06 $get_url = $discuz_url .'/space.php?do=home'; //我的帖子
07
08 $post_fields = array();
09 //以下两项不需要修改
10 $post_fields['loginfield'] = 'username';
11 $post_fields['loginsubmit'] = 'true';
12 //用户名和密码,必须填写
13 $post_fields['username'] = '你的用户名';
14 $post_fields['password'] = '你的密码';
15 $post_fields['refer'] = 'space.php?do=home';
16
17 //获取表单FORMHASH
18 $ch = curl_init($login_url);
19 curl_setopt($ch, CURLOPT_HEADER, 0);
20 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
21 $contents = curl_exec($ch);
22 curl_close($ch);
23 preg_match('/input\s*type="hidden"\s*name="formhash"\s*value="(.*?)"\s*\//i', $contents, $matches);
24 if(!empty($matches)) {
25 $formhash = $matches[1];
26 } else {
27 die('Not found the forumhash.');
28 }
29 $post_fields['formhash']=$formhash;
30 //POST数据,获取COOKIE
31 $cookie_file = dirname(__FILE__) . '/cookie.txt';
32 //$cookie_file = tempnam('/tmp');
33 $ch = curl_init($login_url);
34 curl_setopt($ch, CURLOPT_HEADER, 0);
35 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
36 curl_setopt($ch, CURLOPT_POST, 1);
37 curl_setopt($ch, CURLOPT_POSTFIELDS, $post_fields);
38 curl_setopt($ch, CURLOPT_COOKIEJAR, $cookie_file);
39 curl_exec($ch);
40 curl_close($ch);
41
42 //带着上面得到的COOKIE获取需要登录后才能查看的页面内容
43 $ch = curl_init($get_url);
44 curl_setopt($ch, CURLOPT_HEADER, 0);
45 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 0);
46 curl_setopt($ch, CURLOPT_COOKIEFILE, $cookie_file);
47 $contents = curl_exec($ch);
48 curl_close($ch);
49
50 var_dump($contents);
51 ?
4、discuz怎么在电脑模拟手机
第一步:打开百度浏览器
如果没有点击这里进行下载:
第二步:使用极速模式
第三步:对着网页空白区域,点击鼠标右键,选择“审查元素”
第四步:在弹出的控制面板中点击手机小图标
第五步:选择要模拟收手机设备
第六步:点击如下图标,将控制面板居右
第七步:点击工具栏上的刷新按钮
第八步:此时就显示的是手机版
回答完毕,如有疑问请继续追问!
5、discuz 3.2 怎么实现登录页面?
用webzip将这个页面下载下来,打开编辑代码将其中的用户登录表格post id 等、所有可以修改的都替换成你网站的参数,上传到你空间,命名login_new.htm
首改网站首页注册地址 让他跳转到login_new.htm上
6、如何在第三方模拟登陆discuz,模拟发帖
你在discuz官方应用中心搜索“dn123”,会有一些采集插件出来,其中这些插件的功能就有模拟登陆discuz,然后自动发布内容,可以研究一下是如何实现的。
关于discuz模拟登录和discuz注册页面的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。