zoukankan      html  css  js  c++  java
  • paip.抓取网页内容java php python

    paip.抓取网页内容--java php python.txt

    作者Attilax  艾龙, EMAIL:1466519819@qq.com
    来源:attilax的专栏
    地址:http://blog.csdn.net/attilax

    //java
    String urlContent = WebpageContent("http://www.123cha.com/ip/?q="+ip,"utf-8");



    ///php
    file_get_contents($url);
     curl_init()>>>curl_exec
     fopen->fread->fclose
     
     
     /python
     urllib.urlopen(url).read()
     response = urllib2.urlopen('http://www.baidu.com/')  
    html = response.read()  
     
     ///ahk
     UrlDownloadToFile, URL, Filename

     
     
     public String downloadPage(String Url, String encode) {
            try {
                URL pageUrl = new URL(Url);
                // Open connection to URL for reading.
                BufferedReader reader = new BufferedReader(new InputStreamReader(
                        pageUrl.openStream(), encode));
                // BufferedReader br = new BufferedReader(new InputStreamReader(in,
                // "gbk"));
                // Read page into buffer.
                String line;
                StringBuffer pageBuffer = new StringBuffer();
                while ((line = reader.readLine()) != null) {
                    pageBuffer.append(line);
                }
                String s = pageBuffer.toString();
                return s;
                // System.out.println(s);
                // return pageBuffer.toString();
            } catch (Exception e) {
                // return null;
                throw new RuntimeException(e);
            }

        }

     
     
     参考:
     php获取网页内容方法总结_php技巧_脚本之家.htm
     Python 3 抓取网页资源的 N 种方法.htm
  • 相关阅读:
    数据预处理
    机器学习--有监督学习和无监督学习
    weka简介
    第10章 接口、继承与多态----类的继承3
    html5 canvas实现梦幻的3D刺猬球
    html5 canvas实现图片玻璃碎片特效
    css3实现的鼠标经过按钮特效
    CSS3 Transitions属性打造动画的下载按钮特效
    纯css3实现的幽灵按钮导航
    几行css3代码实现超炫加载动画
  • 原文地址:https://www.cnblogs.com/attilax/p/15199300.html
Copyright © 2011-2022 走看看