|
|
@ -1,39 +1,26 @@
|
|
|
|
package us.codecraft.webmagic.proxy;
|
|
|
|
package us.codecraft.webmagic.proxy;
|
|
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
import org.apache.http.HttpHost;
|
|
|
|
import java.io.FileInputStream;
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
import java.io.FileOutputStream;
|
|
|
|
import us.codecraft.webmagic.utils.FilePersistentBase;
|
|
|
|
import java.io.IOException;
|
|
|
|
import us.codecraft.webmagic.utils.ProxyUtils;
|
|
|
|
import java.io.ObjectInputStream;
|
|
|
|
|
|
|
|
import java.io.ObjectOutputStream;
|
|
|
|
import java.io.*;
|
|
|
|
import java.net.InetAddress;
|
|
|
|
import java.net.InetAddress;
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
import java.net.UnknownHostException;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.*;
|
|
|
|
import java.util.HashMap;
|
|
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
import java.util.NoSuchElementException;
|
|
|
|
|
|
|
|
import java.util.Timer;
|
|
|
|
|
|
|
|
import java.util.TimerTask;
|
|
|
|
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
import java.util.Map.Entry;
|
|
|
|
import java.util.concurrent.BlockingQueue;
|
|
|
|
import java.util.concurrent.BlockingQueue;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
import java.util.concurrent.DelayQueue;
|
|
|
|
import java.util.concurrent.DelayQueue;
|
|
|
|
|
|
|
|
|
|
|
|
import org.apache.http.HttpHost;
|
|
|
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import us.codecraft.webmagic.utils.FilePersistentBase;
|
|
|
|
|
|
|
|
import us.codecraft.webmagic.utils.ProxyUtils;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Pooled Proxy Object
|
|
|
|
* Pooled Proxy Object
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author yxssfxwzy@sina.com <br>
|
|
|
|
* @author yxssfxwzy@sina.com <br>
|
|
|
|
* @since 0.5.1
|
|
|
|
|
|
|
|
* @see Proxy
|
|
|
|
* @see Proxy
|
|
|
|
|
|
|
|
* @since 0.5.1
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class ProxyPool {
|
|
|
|
public class ProxyPool {
|
|
|
|
|
|
|
|
|
|
|
@ -87,9 +74,9 @@ public class ProxyPool {
|
|
|
|
|
|
|
|
|
|
|
|
private void setFilePath() {
|
|
|
|
private void setFilePath() {
|
|
|
|
String tmpDir = System.getProperty("java.io.tmpdir");
|
|
|
|
String tmpDir = System.getProperty("java.io.tmpdir");
|
|
|
|
String path = tmpDir + "webmagic\\lastUse.proxy";
|
|
|
|
String path = tmpDir + FilePersistentBase.PATH_SEPERATOR + "webmagic" + FilePersistentBase.PATH_SEPERATOR + "lastUse.proxy";
|
|
|
|
if (tmpDir != null && new File(tmpDir).isDirectory()) {
|
|
|
|
if (tmpDir != null && new File(tmpDir).isDirectory()) {
|
|
|
|
fBase.setPath(tmpDir + "webmagic");
|
|
|
|
fBase.setPath(tmpDir + FilePersistentBase.PATH_SEPERATOR + "webmagic");
|
|
|
|
File f = fBase.getFile(path);
|
|
|
|
File f = fBase.getFile(path);
|
|
|
|
if (!f.exists()) {
|
|
|
|
if (!f.exists()) {
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|