Environmental Python3.6
#!/usr/bin/env python#-*-coding=utf-8 -*-#AUTHOR:d Uwentaoimport requestsimport reprint (" Get proxy IP Address ") header = { " user-agent ":" mozilla/5.0 (windows nt 10.0;&NBSP;WOW64) AppleWebKit/537.36 (Khtml, like gecko) Chrome/49.0.2623.221 safari/537.36 se 2.x metasr 1.0 "}reponse = requests.get (" https:// www.kuaidaili.com/free/inha/", header) reponse.encoding= ' utf-8 ' html = reponse.text#p = r ' <tr><td data-title= "IP" > (. *?) </td><td data-title= "PORT" > (. *?) </td><td data-title= "anonymous Degree" > (. *?) </td><td data-title= "Type" > (. *?) </td><td data-title= "Location" > (. *?) </td><td data-title= "Response Speed" > (. *?) </td><td data-title= "Last Verified Time" > (. *?) </td></tr> ' ip = r ' <td data-title= "IP" > (. *?) </td> ' Ip = re.findall (ip,html,re. M|re. S) Dk&nbsP;= r ' <td data-title= "PORT" > (. *?) </td> ' Dk = re.findall (dk,html,re. M|re. S) F=open ("Ip_list.txt", "a") FOR&NBSP;IP&NBSP;IN&NBSP;IP:&NBSP;&NBSP;&NBSP;&NBSP;FOR&NBSP;DK&NBSP;IN&NBSP;DK: ip_dk = ip + ":" + dk + "\ n" f.write (IP_DK) f.close () print ("Save Complete")
Python Crawl proxy IP