Class Program
Public Shared masterPorxyList As List(Of proxy) = New List(Of proxy)()

Public Class proxy
Public ip As String
Public port As String
Public speed As Integer

Public Sub New(ByVal pip As String, ByVal pport As String, ByVal pspeed As Integer)
Me.ip = pip
Me.port = pport
Me.speed = pspeed
End Sub
End Class

Private Shared Sub getProxyList(ByVal pageIndex As Object)
Dim urlCombin As String = "http://www.xicidaili.com/wt/" & pageIndex.ToString()
Dim catchHtml As String = catchProxIpMethord(urlCombin, "UTF8")
Dim doc As HtmlAgilityPack.HtmlDocument = New HtmlAgilityPack.HtmlDocument()
doc.LoadHtml(catchHtml)
Dim table As HtmlNode = doc.DocumentNode.SelectSingleNode("//div[@id='wrapper']//div[@id='body']/table[1]")
Dim collectiontrs As HtmlNodeCollection = table.SelectNodes("./tr")

For i As Integer = 0 To collectiontrs.Count - 1
Dim itemtr As HtmlAgilityPack.HtmlNode = collectiontrs(i)
Dim collectiontds As HtmlNodeCollection = itemtr.ChildNodes

If i > 0 Then
Dim itemtdip As HtmlNode = CType(collectiontds(3), HtmlNode)
Dim itemtdport As HtmlNode = CType(collectiontds(5), HtmlNode)
Dim itemtdspeed As HtmlNode = CType(collectiontds(13), HtmlNode)
Dim ip As String = itemtdip.InnerText.Trim()
Dim port As String = itemtdport.InnerText.Trim()
Dim speed As String = itemtdspeed.InnerHtml
Dim beginIndex As Integer = speed.IndexOf(":", 0, speed.Length)
Dim endIndex As Integer = speed.IndexOf("%", 0, speed.Length)
Dim subSpeed As Integer = Integer.Parse(speed.Substring(beginIndex + 1, endIndex - beginIndex - 1))

If subSpeed > 90 Then
Dim temp As proxy = New proxy(ip, port, subSpeed)
masterPorxyList.Add(temp)
Console.WriteLine("当前是第:" & masterPorxyList.Count.ToString() & "个代理IP")
End If
End If
Next
End Sub

Private Shared Function catchProxIpMethord(ByVal url As String, ByVal encoding As String) As String
Dim htmlStr As String = ""

Try

If Not String.IsNullOrEmpty(url) Then
Dim request As WebRequest = WebRequest.Create(url)
Dim response As WebResponse = request.GetResponse()
Dim datastream As Stream = response.GetResponseStream()
Dim ec As Encoding = Encoding.[Default]

If encoding = "UTF8" Then
ec = Encoding.UTF8
ElseIf encoding = "Default" Then
ec = Encoding.[Default]
End If

Dim reader As StreamReader = New StreamReader(datastream, ec)
htmlStr = reader.ReadToEnd()
reader.Close()
datastream.Close()
response.Close()
End If

Catch
End Try

Return htmlStr
End Function

Private Shared Sub Main(ByVal args As String())
For i As Integer = 1 To 15
ThreadPool.QueueUserWorkItem(AddressOf getProxyList, i)
Next

Console.Read()
End Sub
End Class

vb.net 多线程爬虫抓取免费代理IP的更多相关文章

  1. C#多线程爬虫抓取免费代理IP

    这里用到一个HTML解析辅助类:HtmlAgilityPack,如果没有网上找一个增加到库里,这个插件有很多版本,如果你开发环境是使用VS2005就2.0的类库,VS2010就使用4.0,以此类推.. ...

  2. PHP简单爬虫 爬取免费代理ip 一万条

    目标站:http://www.xicidaili.com/ 代码: <?php require 'lib/phpQuery.php'; require 'lib/QueryList.php'; ...

  3. 简单爬虫-爬取免费代理ip

    环境:python3.6 主要用到模块:requests,PyQuery 代码比较简单,不做过多解释了 #!usr/bin/python # -*- coding: utf-8 -*- import ...

  4. c#批量抓取免费代理并验证有效性

    之前看到某公司的官网的文章的浏览量刷新一次网页就会增加一次,给人的感觉不太好,一个公司的官网给人如此直白的漏洞,我批量发起请求的时候发现页面打开都报错,100多人的公司的官网文章刷新一次你给我看这个, ...

  5. golang爬取免费代理IP

    golang爬取免费的代理IP,并验证代理IP是否可用 这里选择爬取西刺的免费代理Ip,并且只爬取了一页,爬取的时候不设置useAgent西刺不会给你数据,西刺也做反爬虫处理了,所以小心你的IP被封掉 ...

  6. 极简代理IP爬取代码——Python爬取免费代理IP

    这两日又捡起了许久不碰的爬虫知识,原因是亲友在朋友圈拉人投票,点进去一看发现不用登陆或注册,觉得并不复杂,就一时技痒搞一搞,看看自己的知识都忘到啥样了. 分析一看,其实就是个post请求,需要的信息都 ...

  7. 码农代理免费代理ip端口字段js加密破解

    起因 之前挖过爬取免费代理ip的坑,一个比较帅的同事热心发我有免费代理ip的网站,遂研究了下:https://proxy.coderbusy.com/. 解密 因为之前爬过类似的网站有了些经验,大概知 ...

  8. Python 爬虫抓取代理IP,并检测联通性

    帮朋友抓了一些代理IP,并根据测试联的通性,放在了不通的文件夹下.特将源码分享 注意: 1,环境Python3.5 2,安装BeautifulSoup4  requests 代码如下: 1 2 3 4 ...

  9. Python多线程爬虫爬取电影天堂资源

    最近花些时间学习了一下Python,并写了一个多线程的爬虫程序来获取电影天堂上资源的迅雷下载地址,代码已经上传到GitHub上了,需要的同学可以自行下载.刚开始学习python希望可以获得宝贵的意见. ...

随机推荐

  1. PL/SQL Developer报错 ORA-12154:tns:could not resolve the connect identifier specified

    PL/SQL Developer使用预先配置数据库报错 ORA-12154:tns:could not resolve the connect identifier specified. 情况描述:我 ...

  2. Unity Built-In Shader造成的运行时内存暴涨

    在某个PC项目中使用了大量的材质球, 并且都使用了自带的Standard Shader, 在编辑器运行的时候, 一切良好, 运行内存只在1G左右, 然而在进行AssetBundle打包之后, EXE运 ...

  3. 在linux下配置jupyter notebook,本地浏览器访问

    1.安装jupyter notebook pip install jupyter 2.生成配置文件 jupyter notebook --generate-config 3.设置登陆密码并生成秘钥 s ...

  4. python安装thrift-sasl提示缺少sasl.h文件

    这其实是在pip安装Cyrus-SASL bindings for Python时报的错误. 由于没有whl文件,都是源码要经过编译之后才能安装. 所以,报这个错误,一般都是缺少安装软件造成的. 不管 ...

  5. 算法学习day01 栈和队列

    1,设计一个算法利用顺序栈的基本运算判断一个字符串是否是回文 解题思路:      由于回文是从前到后和从后到前读都是一样的,所以只要将待判断的字符串颠倒 然后与原字符串相比较,就可以决定是否是回文了 ...

  6. 201871010125 王玉江 《面向对象程序设计(Java)》第八周实验总结

    项目 内容 这个作业属于哪个课程 https://www.cnblogs.com/nwnu-daizh/ 这个作业的要求在哪里 https://www.cnblogs.com/nwnu-daizh/p ...

  7. nodejs接收post请求参数

    原文 https://blog.csdn.net/u013263917/article/details/78682270#1.2 nodejs接收post请求参数1.1-浏览器发送post请求参数的方 ...

  8. 洛谷 P1628 合并序列

    洛谷 P1628 合并序列 题目传送门 题目描述 有N个单词和字符串T,按字典序输出以字符串T为前缀的所有单词. 输入格式 输入文件第一行包含一个正整数N: 接下来N行,每行一个单词,长度不超过100 ...

  9. HTML基础五-starrysky页面动起来

    Starrysky前端框架 链接:https://pan.baidu.com/s/1P8mPrHZjyRtzw1NWnAx-9w 提取码:cjl5 接口文档:https://www.showdoc.c ...

  10. ABP 异常

    abp自己封装了一个异常的基类: 此异常用于直接显示给用户,可用于返回一些提示,如:密码错误,用户名不能为空等. 参数 Severity :异常的严重程度 是个Enum类型 基本使用: 系统常见异常: ...