找回密码
 立即注册
查看: 12048|回复: 7
打印 上一主题 下一主题

技术贴教你如何访问日本著名网站dmm

[复制链接]

421

主题

453

帖子

453

积分

牛皮县令

Rank: 25Rank: 25Rank: 25Rank: 25Rank: 25Rank: 25Rank: 25

UID
73
精华
0
兔币
1090
牛币
641
贡献
50
在线时间
73 小时
注册时间
2015-5-17
跳转到指定楼层
楼主
发表于 2016-8-10 14:24:15 | 只看该作者 |只看大图 回帖奖励 |倒序浏览 |阅读模式


先上图看下效果


之前使用xx-net一翻一墙,但是一直都无法访问dmm,正好arzon被封,简直没法按系列或者按女优去搜番号,后来自己研究了下,发现在使用xx-net的gae代理是可以访问的,不知道为什么配合xx-net就不行,所以自己写了一个很小的程序,简单实现了下代理访问

注意!想用我这个方法实现访问dmm必须先启动xx-net,可以百度下xx-net教程,githup上就有
https://github.com/XX-net/XX-Net/wiki/XXNET%E8%B6%85%E8%AF%A6%E7%BB%86%E6%95%99%E7%A8%8B

下面说下怎么搞能访问到dmm
先到这里下载压缩包 http://pan点baidu.com/s/1eSPqZ2y 提取码
游客,如果您要查看本帖隐藏内容请回复


这个是我把写好的代理直接部署在tomcat下了,直接把压缩包解压到任何目录,启动 apache-tomcat-7.0.59\bin\startup.bat  启动成功后打开浏览器访问
http://127.0.0.1:8080/web-jersey/rest/users


就可以访问dmm了,这个我做了一个非常非常简单的代理,把css放到了项目里,但是所有的js都干掉了,所以可能样式上稍稍不太给力,这个我以后看看有机会再优化下
暂时来说可以点大部分链接访问了


如果有人想研究研究,那我不介意把代码贴上来,因为真的十分简单,全加起来不到70行代码,就是写的比较恶心,毕竟就30分钟写出来,写完就立马贴上来了,所以比较粗糙

複製代碼
import org.apache.ht@Gue^33D-9#2nv@tp.ht@Gue^33D-9#2nv@tpHost;
import org.apache.ht@Gue^33D-9#2nv@tp.client.methods.CloseablehttpResponse;
import org.apache.ht@Gue^33D-9#2nv@tp.client.methods.ht@Gue^33D-9#2nv@tpGet;
import org.apache.ht@Gue^33D-9#2nv@tp.impl.client.CloseablehttpClient;
import org.apache.ht@Gue^33D-9#2nv@tp.impl.client.ht@Gue^33D-9#2nv@tpClients;
import org.apache.ht@Gue^33D-9#2nv@tp.impl.conn.DefaultProxyRoutePlanner;
import org.apache.ht@Gue^33D-9#2nv@tp.util.EntityUtils;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;

/**
* Created by Administrator on 2016/8/4.
*/
@Path(\\"/users\\")
public class controller {

    @GET
    @Produces(MediaType.TEXT_HTML)
    public String getIt() throws Exception{
        httpGet get = new httpGet(\\"http://www.dmm.co.jp/digital/videoa/-/list/=/sort=ranking/\\");
        httpHost proxy = new httpHost(\\"127.0.0.1\\", 8087);
        DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
        CloseablehttpClient client = ht@Gue^33D-9#2nv@tpClients.custom()
                .setRoutePlanner(routePlanner)
                .build();
        CloseablehttpResponse response = client.execute(get);
        String content = EntityUtils.toString(response.getEntity(), \\"utf-8\\");
        Document document = Jsoup.parse(content);
//        Element element = document.getElementById(\\"w\\");
        Element element = document.body();
        return handle(element.html());
    }

    @Path(\\"get\\")
    @GET
    @Produces(MediaType.TEXT_HTML)
    public String getUrl(@QueryParam(\\"url\\") String url) throws Exception{
        System.out.println(url);
        httpGet get = new httpGet(url);
        httpHost proxy = new httpHost(\\"127.0.0.1\\", 8087);
        DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
        CloseablehttpClient client = ht@Gue^33D-9#2nv@tpClients.custom()
                .setRoutePlanner(routePlanner)
                .build();
        CloseablehttpResponse response = client.execute(get);
        String content = EntityUtils.toString(response.getEntity(), \\"utf-8\\");
        Document document = Jsoup.parse(content);
//        Element element = document.getElementById(\\"w\\");
        Element element = document.body();
        System.out.println(element.html());
        return handle(element.html());
    }

    private String handle(String html){
        String content = html.replaceAll(\\"href=\\\"/\\",\\"href=\\\"http://127.0.0.1:8080/rest/users/get?url=http://www.dmm.co.jp/\\").replaceAll(\\"href=\\\"http://www\\",\\"href=\\\"http://127.0.0.1:8080/rest/users/get?url=http://www\\");
        content = content.replaceAll(\\"(?s)<script.*?</script>\\",\\"\\");
        content = \\"<!DOCTYPE html><html><head><link href=\\\"/static/base.css\\\" media=\\\"screen\\\" rel=\\\"stylesheet\\\" type=\\\"text/css\\\" /><link href=\\\"/static/list.css\\\" media=\\\"screen\\\" rel=\\\"stylesheet\\\" type=\\\"text/css\\\" /><link href=\\\"/static/digital.css\\\" media=\\\"screen\\\" rel=\\\"stylesheet\\\" type=\\\"text/css\\\" /></head><body name=\\\"dmm_main\\\">\\"+content+\\"</body></html>\\";
        return content;
    }
}


主要是jersey和httpclient jsoup实现的,pom文件

複製代碼
<?xml version=\\"1.0\\" encoding=\\"UTF-8\\"?>
<project xmlns=\\"http://maven.apache.org/POM/4.0.0\\"
         xmlns:xsi=\\"http://www.w3.org/2001/XMLSchema-instance\\"
         xsi:schemaLocation=\\"http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd\\">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.xz.web</groupId>
    <artifactId>web-jersey</artifactId>
    <version>1.0-SNAPSHOT</version>
    <packaging>war</packaging>

    <dependencies>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-core</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-server</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>com.sun.jersey</groupId>
            <artifactId>jersey-client</artifactId>
            <version>1.8</version>
        </dependency>
        <dependency>
            <groupId>javax.ws.rs</groupId>
            <artifactId>jsr311-api</artifactId>
            <version>1.1.1</version>
        </dependency>
        <dependency>
            <groupId>asm</groupId>
            <artifactId>asm</artifactId>
            <version>3.3.1</version>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.3.2</version>
        </dependency>
        <dependency>
            <groupId>org.jsoup</groupId>
            <artifactId>jsoup</artifactId>
            <version>1.7.2</version>
        </dependency>
    </dependencies>
    <build>
        <finalName>web-jersey</finalName>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <configuration>
                    <compilerArguments>
                        <source>1.7</source>
                        <target>1.7</target>
                        <encoding>UTF-8</encoding>
                    </compilerArguments>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <configuration>
                    <skip>true</skip>
                </configuration>
            </plugin>
            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.2.2.v20140723</version>
                <configuration>
                    <httpConnector>
                        <port>8080</port>
                    </httpConnector>
                    <!-- 在很短的时间间隔内在扫描web应用检查是否有改变,如果发觉有任何改变则自动热部署。默认为0,表示禁用热部署检查。任何一个大于0的数字都将表示启用。 -->
                    <scanIntervalSeconds>10</scanIntervalSeconds>
                    <webAppConfig>
                        <!--jetty插件启动后的访问路径: http://localhost:8080/testdemo-->
                        <contextPath>/</contextPath>
                        <tempDirectory>${project.build.directory}/work
                        </tempDirectory>
                    </webAppConfig>
                </configuration>
            </plugin>
        </plugins>
    </build>
</project>

回复

使用道具 举报

41

主题

106

帖子

106

积分

牛皮村长

Rank: 20Rank: 20Rank: 20Rank: 20Rank: 20

UID
2897
精华
0
兔币
82
牛币
294
贡献
3
在线时间
17 小时
注册时间
2016-7-1
沙发
发表于 2016-8-10 15:07:12 | 只看该作者
日本著名网站dmm,这是个好东西,楼主的东西更好,感谢楼主
回复 支持 反对

使用道具 举报

0

主题

8

帖子

8

积分

牛皮草民

Rank: 10Rank: 10Rank: 10

UID
5325
精华
0
兔币
0
牛币
4
贡献
0
在线时间
2 小时
注册时间
2017-2-18
板凳
发表于 2017-2-18 19:16:03 | 只看该作者
谢谢分享想问下楼主有办法上PasteBin吗?
回复 支持 反对

使用道具 举报

0

主题

580

帖子

580

积分

牛皮知州

Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30

UID
142
精华
0
兔币
-45
牛币
6
贡献
0
在线时间
0 小时
注册时间
2015-11-8
地板
发表于 2017-8-29 23:21:14 | 只看该作者
收藏了,怕楼主删了!
回复 支持 反对

使用道具 举报

0

主题

568

帖子

568

积分

牛皮知州

Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30

UID
187
精华
0
兔币
-38
牛币
7
贡献
0
在线时间
0 小时
注册时间
2015-11-11
5#
发表于 2017-8-30 12:40:06 | 只看该作者
看了这么多帖子,第一次看到这么经典的!       
回复 支持 反对

使用道具 举报

0

主题

3

帖子

3

积分

牛皮草民

Rank: 10Rank: 10Rank: 10

UID
8983
精华
0
兔币
12
牛币
205
贡献
0
在线时间
1 小时
注册时间
2017-9-9
6#
发表于 2017-10-28 16:46:13 | 只看该作者
谢谢楼主分享,大力支持
回复 支持 反对

使用道具 举报

0

主题

235

帖子

236

积分

永久VIP会员

Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30Rank: 30

UID
15875
精华
0
兔币
134
牛币
30
贡献
0
在线时间
11 小时
注册时间
2018-2-23
7#
发表于 2018-2-23 06:15:13 | 只看该作者
hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
回复 支持 反对

使用道具 举报

0

主题

25

帖子

26

积分

牛皮草民

Rank: 10Rank: 10Rank: 10

UID
18046
精华
0
兔币
11
牛币
4
贡献
0
在线时间
2 小时
注册时间
2018-5-19
8#
发表于 2018-5-19 21:24:27 | 只看该作者
http://pan点baidu.com/s/1eSPqZ2y
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表