python3.x: Get proxy IP

Source: Internet
Author: User

Tag: Class Port request Ali like STS main end returns

python3.x: Get proxy IP

Get proxy IP, code:

#Python3#Domestic High Stealth proxy IP website: http://www.xicidaili.com/nn/#Crawling Home proxy IP address fromBs4ImportBeautifulSoupImportRequestsImportRandom#Get home IP listdefget_ip_list (URL, headers): Web_data= Requests.get (URL, headers=headers) Soup= BeautifulSoup (Web_data.text,'lxml') IPs= Soup.find_all ('TR') Ip_list= []    #Extract IP list    #usage of range (): Range (1,5) #代表从1到5 (not including 5)     forIinchRange (1, Len (IPs)): Ip_info=Ips[i] TDs= Ip_info.find_all ('TD') ip_list.append (tds[5].text.lower () +'://'+ Tds[1].text +':'+ tds[2].text)returnip_list#randomly get an IPdefget_random_ip (ip_list):#randomly get an IP (from the returned IP list)PROXY_IP =Random.choice (ip_list)returnproxy_ip#Testif __name__=='__main__':    #Domestic High Stealth proxy IPURL ='http://www.xicidaili.com/nn/'Headers= {        'user-agent':'mozilla/5.0 (Windows NT 6.1; Win64; x64) applewebkit/537.36 (khtml, like Gecko) chrome/53.0.2785.143 safari/537.36'    }    #Get home IP listip_list = get_ip_list (URL, headers=headers)#random extraction of an IPIP =get_random_ip (ip_list)Print('Proxy IP Address:'+ IP)

Commonly used proxy IP addresses:

1, West Thorn free proxy IP:http://www.xicidaili.com/

2, domestic high stealth proxy IP:http://www.xicidaili.com/nn/

3,66 free agent network:http://www.66ip.cn/

Integrated Man
Links:http://www.cnblogs.com/lizm166/p/8191305.html
Source: Blog Park
Copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please specify the source.

python3.x: Get proxy IP

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.