欢迎各位兄弟 发布技术文章

这里的技术是共享的

You are here

抓取qq的代码 可能 需要用到的 转换 img的src代码

shiping1 的头像
<script>
    (function($){
        function changeData(data, tag){
            for(var i = 0; i < data.length; i++){
                if(!data[i].hasAttribute("data-src") && data[i].hasAttribute("src") && (data[i].getAttribute("src")).lastIndexOf('http://', 0) === 0 && (data[i].getAttribute("src")).indexOf('weixinduba.com/') == -1){
                    data[i].setAttribute("data-src", data[i].getAttribute("src"));
                }
                if(data[i].hasAttribute("data-src")){
                    datasrc = data[i].getAttribute("data-src");
                    datasrc = datasrc.replace("https://v.qq.com/", 'http://v.qq.com/')
                    data[i].setAttribute("src", (tag == 'image' && datasrc.indexOf('http://read.html5.qq.com/image') == -1) ? "http://www.weixinduba.com/a.php?img=" + datasrc : datasrc);
                    data[i].removeAttribute("data-src");
                }
            }
        }
        var imgs = document.getElementsByTagName('img');
        var videos = document.getElementsByClassName('video_iframe');
        changeData(imgs, 'image');
        changeData(videos, 'video');

        /*$('#page-content img').each(function(index, el) {
         $(el).attr({src:'https://'+window.location.host+'/Home/Index/images?url='+$(el).data('src')+''});

         $(el).attr('data-src',null);
         });*/
        var doc = document;

        var title = doc.getElementsByTagName('title')[0].innerHTML;

        var head = doc.getElementsByTagName('head')[0];
        var meta = doc.createElement('meta');
        meta.name = 'description';

        meta.content = title;
        head.appendChild(meta);

        var url = window.location;
        $.urlName = function(name){
            var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"),
                    r   = url.search.substr(1).match(reg);
            return r == null ? null : r;
        };
        $.urlRemove = function(name){
            var r = $.urlName(name);
            return r == null ? null : url.href.replace(r[0],'');
        }
    })(jQuery);
</script>

只需要用上面的代码就行


meta name="viewportcontent="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
我这里下面拿了人家用的还有其它的代码,可能以后会用到吧
meta name="viewport" content="width=device-width,initial-scale=1.0,maximum-scale=1.0,user-scalable=0" />
  
 <div style="position:fixed;bottom:0.5px;width:100%;" class="ft">
 <a href="#" class="close" style="margin-left:10px"> X </a>
 <a href="tel:18020264413" style="position:absolute;right:50px;top:5px"><img src="/Public/Home/Images/carve/tel.gif"/></a> <a href="http://m.hncvw.com/blc/">
 <img src="/Uploads/Download/KzMzwvUvxpQXIjwpnE9MmNfkBzSGgAhBJlyIK5TE5TVrXwk4g3vwD_h5FokeeolQ1459152071.jpg" width="100%" class="ads"/>
 </a>
 </div>
 <div style="text-align:center;color:#bbb;font-size:14px">推广10612</div>
 <div class="qr" style="text-align:center;display:block;background:#fff">
 <img src="/Uploads/Download/rD1hqvKoXBK4kHNNbhTbWz86mE4RYkVss5DKBMJa3ZfURx0dzIDiLpFaDUPEriBv1458808182.jpg" style="width:100%"/>
 </div>
 <script src='http://apps.bdimg.com/libs/jquery/2.1.4/jquery.min.js'></script>
  
 <script type="text/javascript" src="http://res.wx.qq.com/open/js/jweixin-1.0.0.js"></script>
 <script language="Javascript">
 //微信分享按钮 显示
 (function(window, undefined){
 document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
 WeixinJSBridge.call('showOptionMenu');
 });
 })(window)
 </script>
 <script>
 (function($){
 function changeData(data, tag){
 for(var i = 0; i < data.length; i++){
 if(!data[i].hasAttribute("data-src") && data[i].hasAttribute("src") && (data[i].getAttribute("src")).lastIndexOf('http://', 0) === 0 && (data[i].getAttribute("src")).indexOf('weixinduba.com/') == -1){
 data[i].setAttribute("data-src", data[i].getAttribute("src"));
 }
 if(data[i].hasAttribute("data-src")){
 datasrc = data[i].getAttribute("data-src");
 datasrc = datasrc.replace("https://v.qq.com/", 'http://v.qq.com/')
 data[i].setAttribute("src", (tag == 'image' && datasrc.indexOf('http://read.html5.qq.com/image') == -1) ? "http://www.weixinduba.com/a.php?img=" + datasrc : datasrc);
 data[i].removeAttribute("data-src");
 }
 }
 }
 var imgs = document.getElementsByTagName('img');
 var videos = document.getElementsByClassName('video_iframe');
 changeData(imgs, 'image');
 changeData(videos, 'video');
  
 /*$('#page-content img').each(function(index, el) {
 $(el).attr({src:'https://'+window.location.host+'/Home/Index/images?url='+$(el).data('src')+''});
  
 $(el).attr('data-src',null);
 });*/
 var doc = document;
  
 var title = doc.getElementsByTagName('title')[0].innerHTML;
  
 var head = doc.getElementsByTagName('head')[0];
 var meta = doc.createElement('meta');
 meta.name = 'description';
  
 meta.content = title;
 head.appendChild(meta);
  
 var url = window.location;
 $.urlName = function(name){
 var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)"),
 r = url.search.substr(1).match(reg);
 return r == null ? null : r;
 };
 $.urlRemove = function(name){
 var r = $.urlName(name);
 return r == null ? null : url.href.replace(r[0],'');
 }
 })(jQuery);
  
 wx.config({
 debug: false,
 appId: 'wxac591d28fb9902cb',
 timestamp:'1460086096',
 nonceStr: '9tu5168dzpufuon6',
 signature:'398a96159f40d136dffa6da6d874b2fbe8bfa6a5',
 jsApiList:['checkJsApi','onMenuShareTimeline','onMenuShareAppMessage','onMenuShareQQ','onMenuShareWeibo','hideMenuItems','showMenuItems','hideAllNonBaseMenuItem','showAllNonBaseMenuItem','translateVoice','startRecord','stopRecord', 'onRecordEnd','playVoice','pauseVoice','stopVoice','uploadVoice','downloadVoice','chooseImage','previewImage','uploadImage','downloadImage','getNetworkType','openLocation','getLocation','hideOptionMenu','showOptionMenu','closeWindow','scanQRCode','chooseWXPay','openProductSpecificView','addCard','chooseCard','openCard','WeixinJSBridgeReady','onBridgeReady']
 });
  
 wx.ready(function () {
 //微信分享数据获取
 var v = {
 w : document.documentElement.clientWidth,
 h : window.screen.height,
 href : window.location.href,
 host : window.location.host,
 _host : window.location.host.split('.'),
 //获取GET参数
 get : 'a:5:{s:2:"id";s:2:"97";s:3:"uid";s:5:"10612";s:3:"url";s:217:"http://mp.weixin.qq.com/s?plg_nld=1&3rd=MzA3MDU4NTYzMw%3D%3D&mid=2666126554&plg_uin=1&idx=1&plg_nld=...";s:4:"cate";s:1:"0";s:6:"submit";s:6:"分享";}',
 path_info : "Advert/caiji_phone_f/id/97/uid/10612",
 title : document.title,
 ref : document.referrer,
 desc : $('meta[name=description]').attr('content'),
 };
 v.temp = v._host[v._host.length-2]+'.'+v._host[v._host.length-1];
 //=====================================================
 function getMsgImage(){
 var img;
 try{
 img = $('img').eq(0).attr('src');
 if(img.indexOf('http://') < 0){
 img = 'http://'+v.host+img;
 }
 }
 catch (e){
 img = ""; //填写图片地址
 }
  
 //return img;
 return img;
 }
  
 function getShareUrl(){
 v.href = code(v.href);
 return v.href = code(v.href);
  
 }
  
 function code(m){
 if(m.indexOf('?code')!=-1){
 return m.substring(0,m.indexOf('?code'))
 }
 if(m.indexOf('&code')!=-1){
 return m.substring(0,m.indexOf('&code'))
 }
 if(m.indexOf('&state')!=-1){
 return m.substring(0,m.indexOf('&state'))
 }
 if(m.indexOf('&submit')!=-1){
 return m.substring(0,m.indexOf('&submit'))
 }
 return m;
 }
  
  
  
 //分享给朋友
 wx.onMenuShareAppMessage({
 title: v.title, //标题
 desc: v.desc, //描述
 link: getShareUrl(), //分享链接网址
 imgUrl: getMsgImage(),//分享图片
 trigger: function (res) {
 //alert('用户点击发送给朋友');
 },
 success: function (res) {
 //alert('已分享');
 v.share_media = 'friend';
 share(v); //记录分享数据
 },
 cancel: function (res) {
 //alert('已取消');
 },
 fail: function (res) {
 //alert(JSON.stringify(res));
 }
 });
 //分享到朋友圈
 wx.onMenuShareTimeline({
 title: v.title, //标题
 link: getShareUrl(), //分享链接网址
 imgUrl: getMsgImage(),//分享图片
 trigger: function (res) {
 //alert(v.rid);
 //alert('用户点击分享到朋友圈');
 },
 success: function (res) {
 //alert('已分享');
 v.share_media = 'timeline';
 share(v); //记录分享数据
 },
 cancel: function (res) {
 //alert('已取消');
 },
 fail: function (res) {
 //alert(JSON.stringify(res));
 }
 });
 //分享到QQ
 wx.onMenuShareQQ({
 title: v.title, //标题
 desc: v.desc, //描述
 link: getShareUrl(), //分享链接网址
 imgUrl: getMsgImage(),//分享图片
 trigger: function (res) {
 alert('用户点击分享到QQ');
 },
 complete: function (res) {
 //alert(JSON.stringify(res));
 },
 success: function (res) {
 //alert('已分享');
 v.share_media = 'qq';
 share(v); //记录分享数据
 },
 cancel: function (res) {
 //alert('已取消');
 },
 fail: function (res) {
 //alert(JSON.stringify(res));
 }
 });
 //分享到微博
 wx.onMenuShareWeibo({
 title: v.title, //标题
 desc: v.desc, //描述
 link: getShareUrl(), //分享链接网址
 imgUrl: getMsgImage(),//分享图片
 trigger: function (res) {
 //alert('用户点击分享到微博');
 },
 complete: function (res) {
 //alert(JSON.stringify(res));
 },
 success: function (res) {
 //alert('已分享');
 v.share_media = 'tenweibo';
 share(v); //记录分享数据
 },
 cancel: function (res) {
 //alert('已取消');
 },
 fail: function (res) {
 //alert(JSON.stringify(res));
 }
 });
 });
 </script>
  
 <script type="text/javascript" language="javascript">
 window.onscroll = function() {
 var scrollTop = $(this).scrollTop(),
 scrollHeight = $(document).height(),
 windowHeight = $(this).height();
  if((scrollTop+1000)>= scrollHeight){
 $('.ft').hide();
 }else{
 $('.ft').show();
 }
 }
  
 function SetWinHeight(obj)
 {
 var win=obj;
 if (document.getElementById)
 {
 if (win && !window.opera)
 {
 if (win.contentDocument && win.contentDocument.body.offsetHeight)
 win.height = win.contentDocument.body.offsetHeight;
 else if(win.Document && win.Document.body.scrollHeight)
 win.height = win.Document.body.scrollHeight;
 }
 }
 }
 document.querySelector('.close').onclick = function(){
 document.querySelector('.ft').style.display = 'none';
 return false;
 }
 $('.ads').click(function(){
 var adid = 97;
 var uid = 10612;
 //alert(uid);
 $.ajax({
 type : 'POST',
 url : '/Shop/Advert/click_data',
 data : {id:adid,uid:uid},
 success : function(response) {
 //alert(response);
 },
 });
 });
 $('#mlog_logs').hide();
  
 /* var video = $('.video_iframe').attr('data-src');
 var newv = video.substring(0,video.indexOf('&width'));
 var ip = $('.video_iframe').parent();
 $('.video_iframe').hide();
 var newifa = document.createElement('iframe');
 newifa.src = newv;
 newifa.width = '100%';
 newifa.height = 240;
 newifa.scrolling = 'no';
 newifa.frameborder = 0;
 $(newifa).appendTo(ip);
 */
 </script>

普通分类: