1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
#/usr/local env python
#coding utf-8
import os
import urllib
from bs4 import BeautifulSoup
def log():
f=open("f:\daili.txt",‘a‘)
f.write(ip)
f.close()
def fenxi():
page = urllib.urlopen(url)
data = page.read()
soup=BeautifulSoup(data)
#print soup
list=soup.find_all(‘span‘)
for i in list:
#print i.get_text()
global ip
ip= i.get_text()
s="\n".join(ip.split(‘#‘))
print s
log()
for i in range(1,10):
if i==1:
url = ‘http://www.youdaili.cn/Daili/http/556.html‘
print url
fenxi()
else:
url = ‘http://www.youdaili.cn/Daili/http/556_‘+str(i)+‘.html‘
print url
fenxi()
运行结果:
||||||||IP知识库最新代理IPwww.Youdaili.Cn07-09免费代理国内外http代理ip地址1.186.200.211:[email protected]#印度
2.135.238.92:[email protected]#哈萨克斯坦
2.181.177.7:[email protected]#伊朗
2.183.155.2:[email protected]#伊朗