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