paip.抓取网页内容--java php python
作者Attilax 艾龙, EMAIL:[email protected]
来源: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
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。