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
作者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