New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
spider 中怎么使用http代理 #96
Comments
我也是,普通的request我就是这么加的proxy,不知道用dotnetspider怎么加 HttpWebRequest Request = (HttpWebRequest)WebRequest.Create("https://www.baidu.com"); |
仅针对我发帖时的3.0.8版(3.x版本略有不同) |
@sanjusss 能提供个demo吗? |
Could someone please provide some code examples on howto implement a custom IProxySupplier? Thanks in advanced! |
Sorry for the delay, if you want to use proxy, i suggest you to checout refactory-5.0 branch. There are lot s of update for use proxy. A lots of proxy provider support WEB API to get proxies, and it return data like: I impl a KuaidailiProxySupplier in the refactory-5.0 branch |
看了源码,还是不太清楚如何使用
在自己代码里这样写的,但是跑不起来,其中123.115.120.182:9000是代理ip地址和端口
`
public static void Run()
{
WebProxy webProxy = new WebProxy();
webProxy.Address = new Uri("http://123.115.120.182:9000");
ProxyInfo proxyInfo = new ProxyInfo(webProxy);
ProxySupplier p = new ProxySupplier(proxyInfo);
HttpProxyPool.Instance = new HttpProxyPool(p);
List buildInfoList = new List();
List untiInfoList = new List();
int sleep = Convert.ToInt32(JsonConfigurationHelper.GetAppSettings("ThreadNum", "SleepTime"));
using (var conn = new SqlConnection(Env.DataConnectionString))
{
buildInfoList = conn.Query("SELECT Building_Id FROM T_UnitInfo WITH(NOLOCK) WHERE ISNULL(Building_Id,'')!='' GROUP BY Building_Id").ToList();
untiInfoList = conn.Query("SELECT Unit_Id FROM T_UnitInfo WITH(NOLOCK) WHERE ISNULL(Unit_Id,'')!='' GROUP BY Unit_Id").ToList();
}
BuildInfoSpider spider = new BuildInfoSpider(buildInfoList, untiInfoList, sleep);
var threadNum = JsonConfigurationHelper.GetAppSettings("ThreadNum", "Number");
spider.ThreadNum = Convert.ToInt32(threadNum);
spider.CycleRetryTimes = 5;
spider.Run();
}
`
The text was updated successfully, but these errors were encountered: