[Original] verify whether the proxy IP address is useful

Source: Internet
Author: User
/// <Summary> /// verify whether the proxy IP address is useful /// </Summary> /// <Param name = "ip"> ip address </param> /// <Param name = "Port"> port number </param> // <returns> returns true </returns> static bool isenabled (string IP, int port) {try {httpwebrequest Req = (httpwebrequest) webrequest. create ("http://www.whatismyip.com.tw/"); WebProxy proxyobject = new WebProxy (IP, Port); // ip address, port number req. proxy = proxyobject; // sets proxy req. useragent = "Mozilla/5. 0 (Windows NT 6.1; RV: 31.0) Gecko/20100101 Firefox/31.0 "; httpwebresponse resp = (httpwebresponse) req. getresponse (); encoding code = encoding. getencoding ("UTF-8"); Using (streamreader sr = new streamreader (resp. getresponsestream (), Code) {If (SR! = NULL) {string strhtml = Sr. readtoend (); matchcollection MC = RegEx. Matches (strhtml, "<H2> (? <Text> .*?) </H2> ", regexoptions. ignorecase); If (MC. count> 0) {groupcollection GC = mc [0]. groups; If (IP = GC ["text"]. value) {return true ;}}} catch {return false ;}

 

[Original] verify whether the proxy IP address is useful

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.