一共有1.5W页 每页亦有100个手机号码
就是说亦150万条数据。。。。
我的思路还是我以前的文章 就是那个把H网站所有图片下载。。。
一样分成两部分 第一部分是把所有页面下载下来 第二部分要正则匹配
这些日子我学到了不少新东西 给输出配色和进度条
先看第一部分
#coding = utf-8
import requests
import threading
import re
from colorama import init,Fore
init(autoreset=True) #颜色模块导入配置
f1 = open('url.txt','a+')
shouye1 = 'http://www.hiphop8.com/more.php?page='
def kaishi():
for i in xrange(1,15003):
shouye = shouye1 + str(i)
print shouye
r = requests.get(url=shouye)
rr = re.findall('<LI><A href="(.*?)" target=_blank',r.content)
for xxx in rr:
print Fore.GREEN + xxx.strip('\n') #输出为绿色
f1.write(xxx + '\n')
thread1 = threading.Thread(target=kaishi()) #多进程
thread1.start
f1.close()
运行效果