• 网页端商品链接转换为手机端链接的部分网址规则


    package com.xinsearch;
    
    public class Rule {
    
    	public String changeWWW(String url) {
    		String nowUrl = null;
    		try {
    			if (url.contains("http://item.taobao.com")) {
    				url = url.replace("http://item.taobao.com",
    						"http://a.m.taobao.com");
    				nowUrl = url.replace("tem.htm?id=", "") + ".html";
    			} else if (url.contains("http://www.360buy.com")) {
    				nowUrl = url.replace("http://www.360buy.com",
    						"http://wap.360buy.com");
    			} else if (url.contains("http://item.vjia.com")) {
    				String temp = url.split("/")[3].split("\\.")[0];
    				nowUrl = "http://m.vjia.com/product/detail/0" + temp + "/0/";
    			} else if (url.contains("http://item.51buy.com/item")) {
    				String temp = url.split("-")[1].split("\\.")[0];
    				nowUrl = "http://m.51buy.com/witem.html?pid="+ temp;
    			} else if (url.contains("http://item.51buy.com/item")) {
    				String temp = url.split("-")[1].split("\\.")[0];
    				nowUrl = "http://m.51buy.com/witem.html?pid=" + temp;
    			} else if (url.contains("http://www.dianping.com")) {
    				String temp = url.split("shop/")[1];
    				nowUrl ="http://m.dianping.com/shop.aspx?pid=" + temp;
    			} else if (url.contains(".lashou.com")) {
    				String temp = url.split("deal/")[1].split("\\.")[0];
    				nowUrl = "http://m.lashou.com/detail.php?id=" + temp;
    			} else if (url.contains(".didatuan.com")) {
    				String temp = url.split("team/")[1];
    				nowUrl = "http://m.didatuan.com/wap/team.php?teamId="+ temp;
    			} else if (url.contains(".dangdang.com")) {
    				String temp = url.split("product_id=")[1];
    				nowUrl = "http://m.dangdang.com/product.php?pid="+ temp;
    //			} else if (url.contains(".m18.com")) {
    //				String temp = url.split("p-")[1].split("\\.")[0];
    //				nowUrl = "http://m.m18.com/Style.aspx?StyleId=" + temp;
    //			} else if (url.contains(".d1.com")) {
    //				String temp = url.split("product/")[1].split("\\?")[0];
    //				nowUrl = "http://m.d1.cn/wap/goods.jsp?productid=" + temp;
    			} else if (url.contains(".ule.com")) {
    				String temp = url.split("item/")[1].split("-")[0];
    				nowUrl = "http://m.ule.com/itemDetail.action?listId=" + temp;
    			} else if (url.contains(".1mall.com")) {
    				String temp = url.split("product/")[1].split("_")[0];
    				nowUrl = "http://m.yihaodian.com/mw/productsquid/"+ temp + "/1/20/";
    			} else if (url.contains(".easy361.com")) {
    				String temp = url.split("goods-")[1].split("\\.")[0];
    				nowUrl = "http://m.easy361.com/goods.php?id="+ temp;
    			} else if (url.contains(".51youpin.com")) {
    				String temp = url.split("goods-")[1].split("\\.")[0];
    				nowUrl ="http://m.51youpin.com/index.php/product/info/productId/" + temp;
    			} else if (url.contains(".17gou.com")) {
    				String temp = url.split("id-")[1].split("\\.")[0];
    				nowUrl = "http://m.17gou.com/product/index/pid/" + temp;
    			} else if (url.contains(".vancl.com")) {
    				String temp = url.split("com/")[1].split("\\.")[0];
    				nowUrl = "http://m.vancl.com/style/index/" + temp;
    			} else if (url.contains(".yintai.com")) {
    				String temp = url.split("itemcode=")[1];
    				nowUrl = "http://m.yintai.com/index.php?product_general/index/itemcode/" + temp;
    			} else if (url.contains(".justyle.com")) {
    				String temp = url.split("ProductGroupId=")[1];
    				nowUrl = "http://m.justyle.com/index.php?/goods/getproducthome/guid/50d7e9ddbac99/navid/2/id/" + temp;
    			} else if (url.contains(".yizhedian.com")) {
    				String temp = url.split("goods-")[1].split("\\.")[0];
    				nowUrl = "http://m.yizhedian.com/goods.php?id=" + temp;
    			} else if (url.contains(".yougou.com")) {
    				String temp = url.split("_")[url.split("_").length - 1]
    						.split("\\.")[0];
    				nowUrl = "http://m.yougou.com/index.php/goods/goodsdetail/productid/"
    						+ temp;
    			} else if (url.contains(".taoxie.com")) {
    				String temp = url.split("-")[1].split("\\.")[0];
    				nowUrl = "http://m.taoxie.com/detail.aspx?id=" + temp;
    			} else if (url.contains(".lefeng.com")) {
    				String temp = url.split("product/")[1].split("\\.")[0];
    				nowUrl = "http://wap.lefeng.com/index.php/goods/tdetail/goodsId/"
    						+ temp;
    			} else if (url.contains(".happigo.com")) {
    				String temp = url.split("/")[url.split("/").length - 1]
    						.split("\\.")[0];
    				nowUrl = "http://m.happigo.com/infog.php?gid=" + temp;
    			} else if (url.contains(".vipshop.com")) {
    				String temp = url.split("-")[1];
    				nowUrl = "http://m.vipshop.com/index.php?v=touch&m=product&brand_id=55397&product_id="
    						+ temp;
    			} else if (url.contains(".xtep.com")) {
    				String temp = url.split("goods_sn=")[1].split("\\.")[0];
    				nowUrl = "http://m.xtep.com.cn/Product/show/id/" + temp
    						+ ".html";
    			} else if (url.contains(".etaoshi.com")) {
    				String temp = url.split("com/")[1];
    				nowUrl = "http://m.etaoshi.com/s/" + temp;
    			} else if (url.contains(".uya100.com")) {
    				String temp = url.split("product")[1].split("\\.")[0];
    				nowUrl = "http://m.uya100.com/Product.aspx?pid=" + temp;
    			} else if (url.contains(".wbiao.cn")) {
    				String temp = url.split("-g")[1].split("\\.")[0];
    				nowUrl = "http://m.wbiao.cn/goods.php?id=" + temp;
    			} else if (url.contains(".suning.com")) {
    				nowUrl = url.replace("http://www", "http://m");
    			} else if (url.contains(".efeihu.com")) {
    				String temp = url.split("Product/")[1].split("\\.")[0];
    				nowUrl = "http://m.efeihu.com/Product/Product.aspx?pno=" + temp;
    			} else if (url.contains(".mya123.com")) {
    				String temp = url.split("product/")[1];
    				nowUrl = "http://m.mya123.com/product/" + temp;
    			} else if (url.contains(".mt100.com")) {
    				nowUrl = url.replace("http://www", "http://m");
    			} else if (url.contains(".didamall.com")) {
    				String temp = url.split("info/")[1];
    				nowUrl = "http://wap.didamall.com/wap/product/info/" + temp;
    			} else if (url.contains(".jiuxian.com")) {
    				String temp = url.split("goods-")[1].split("\\.")[0];
    				nowUrl = "http://m.jiuxian.com/goods/view/" + temp;
    			} else if (url.contains(".crabchina.com")) {
    				nowUrl = url.replace("http://www", "http://m");
    			} else if (url.contains(".yesmywine.com")) {
    				String temp = url.split("goods/")[1].split("\\.")[0];
    				nowUrl = "http://m.yesmywine.com/index.php/goods/index/goodsId/"
    						+ temp;
    			} else if (url.contains(".winenice.com")) {
    				String temp = url.split("detail_")[1].split("\\.")[0];
    				nowUrl = "http://m.winenice.com/Product/Product_Information"
    						+ temp + ".html";
    			} else if (url.contains(".fantong.com")) {
    				nowUrl = url.replace("http://www", "http://m");
    			} else if (url.contains(".nuomi.com")) {
    				String temp = url.split("deal/")[1].split("\\.")[0];
    				nowUrl = "http://m.nuomi.com/bj/deal/" + temp;
    			} else if (url.contains(".meituan.com")) {
    				String temp = url.split("deal/")[1].split("\\.")[0];
    				nowUrl = "http://i.meituan.com/beijing/deal/" + temp + ".html";
    			} else if (url.contains(".manzuo.com")) {
    				String temp = url.split("combine/")[1];
    				nowUrl = "http://m.manzuo.com/beijing/" + temp;
    			} else if (url.contains(".jumei.com")) {
    				String temp = url.split("deal/")[1].split("\\.")[0];
    				nowUrl = "http://m.jumei.com/i/MobileWap/deal_view?hash_id="
    						+ temp;
    			} else if (url.contains(".mengmai.com")) {
    				String temp = url.split("id=")[1];
    				nowUrl = "http://m.mengmai.com/team.php?id=" + temp;
    			} else if (url.contains(".17mh.com")) {
    				String temp = url.split("xhy-")[1].split("\\.")[0];
    				nowUrl = "http://m.17mh.com/m.php?m=Goods&a=show&id=" + temp;
    			} else if (url.contains("misstuan.com")) {
    				String temp = url.split("id=")[1];
    				nowUrl = "http://m.misstuan.com/team.php?id=" + temp;
    			} else if (url.contains(".china-pub.com")) {
    				String temp = url.split("com/")[1];
    				nowUrl = "http://m.china-pub.com/BookInfo.aspx?id=" + temp;
    			} else if (url.contains(".bookschina.com")) {
    				String temp = url.split("com/")[1].split("\\.")[0];
    				nowUrl = "http://m.bookschina.com/BOOK_DETAIL/product.aspx?book_id="
    						+ temp;
    			} else if (url.contains(".21yod.com")) {
    				String temp = url.split("/")[5].split("\\.")[0];
    				nowUrl = "http://wap.21yod.com/wap/wap!productdetail.html2?pid="
    						+ temp;
    			} else if (url.contains(".yaofang.cn")) {
    				String temp = url.split("goods-")[1].split("\\.")[0];
    				nowUrl = "http://m.yaofang.cn/p/brief/" + temp;
    			} else if (url.contains(".dooland.com")) {
    				String temp = url.split("book/")[1];
    				nowUrl = "http://www.dooland.com/book/" + temp;
    			} else if (url.contains(".9217tuan.com")) {
    				String temp = url.split("id=")[1];
    				nowUrl = "http://wap.9217tuan.com/team.php?id=" + temp;
    			} else {
    				return null;
    
    			}
    		} catch (Exception e) {
    			return null;
    		}
    		return nowUrl;
    	}
    
    	public static void main(String[] args) {
    		String url = "http://www.360buy.com/product/776025.html";
    		System.out.println(new Rule().changeWWW(url));
    	}
    
    	public static String[] mUrls = { "aibang", "ouku", "dianping", "tuan800",
    			"lashou", "didatuan", "taobao", "tmall", "dangdang", "yihaodian",
    			"m18", "d1", "ule", "1mall", "easy361", "51youpin", "17gou",
    			"vancl", "yintai", "justyle", "vjia", "nop", "sportica", "doin",
    			"yizhedian", "yougou", "paixie", "taoxie", "s", "lefeng", "naruko",
    			"aimer", "chinadrtv", "happigo", "vipshop", "xtep", "cpdyj",
    			"5173", "5biying", "etaoshi", "mayi", "zocai", "ctfeshop",
    			"lvshou", "360kad", "yaofang", "jxdyf", "uemall", "aolai",
    			"bookschina", "china-pub", "oyeah", "misstuan", "17mh", "mengmai",
    			"365h", "napai", "qinqin", "shuangtuan", "juqi", "didatuan",
    			"jumei", "manzuo", "meituan", "nuomi", "aoyou", "998", "airizu",
    			"maizuo", "tieyou", "fantong", "podinns", "qmango", "zhuna",
    			"lvmama", "wangpiao", "winenice", "yesmywine", "crabchina",
    			"jiuxian", "didamall", "mt100", "uya100", "mya123", "wbiao",
    			"efeihu", "51buy", "suning", "newegg" };
    	public static String[] wapUrls = { "etao", "360buy", "55bbs", "17gou",
    			"happigo", "51talk", "5173", "5biying", "8791", "21yod", "yaofang",
    			"dooland", "99read", "mengmai", "9217tuan", "meituan", "99inn",
    			"aoyou", "tieyou", "fantong", "qmango", "zhuna", "lenonle",
    			"winenice", "lingshi", "didamall", "huimai100", "lefeng", "vzi800",
    			"paixie", "mbaobao", "banggo" };
    }
    

      上面给出的代码是部分网页端商品链接转换为手机端链接的规则。为安卓开发的时的转换。

  • 相关阅读:
    java 文件及流读取
    Image对象及其子类BufferedImage
    形状特征提取-Hu不变矩(转载)
    图像的灰度共生矩阵(转载)
    如何实现图片逐渐加载逐渐显示 转载
    JavaScript的函数和事件(转)
    Java图像文件的读写
    图像处理之常用颜色RGB、灰度值
    Hadoop之TaskInputOutputContext类
    ajax获取城市和相应的地区
  • 原文地址:https://www.cnblogs.com/tomcattd/p/2842054.html
Copyright © 2020-2023  润新知