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
  • 相关阅读:
    .net中连接远程目录的解决方案
    VS2008+Window Mobile开发环境的搭建(转)
    安装任何版本ActiveSync都出错原因
    问题让人开始慢慢的思考
    [原创]EasyUI的TreeGrid查询功能实现
    听客户说然后再做开发
    EasyUI的DataGrid合击汇总页脚使用教程
    ASP.NET MVC 使用AderTemplate模板引擎进行视图显示
    C#的JSON数据格式转换方法
    Delphi使用ReportMachine制作小计和总计报表
  • 原文地址:https://www.cnblogs.com/attilax/p/15199300.html
Copyright © 2011-2022 走看看