批量获取手机号归属地

用py写了一个获取手机所在地区的工具。哈哈,纯当练习之用。

#####phone.txt内容####
11位手机
11位手机

#######################

<br />
# coding:UTF-8<br />
import urllib</p>
<p>f = open(&quot;phone.txt&quot;)<br />
line_list = f.readlines()<br />
all_lines = &quot;&quot;<br />
address = &quot;http://...?amount=10000&amp;callname=getPhoneNumInfoExtCallback&amp;mobile=&quot;<br />
for lines in line_list:<br />
    phone = &quot;&quot;.join(lines.split())<br />
    try:<br />
        html = urllib.urlopen(address + phone).read()<br />
        all_lines += &quot;%s\t%s\t%s\n&quot; % (html[int(html.index(&quot;le:'&quot;)) + 4 : int(html.index(&quot;',province&quot;))], html[int(html.index(&quot;sp:'&quot;)) + 4 : int(html.index(&quot;',stock&quot;))], html[int(html.index(&quot;ce:'&quot;)) + 4 : int(html.index(&quot;',isp&quot;))])<br />
    except Exception, e:<br />
        print e.args<br />
        pass<br />
o = open('phone-data.txt', 'a')<br />
o.writelines(all_lines)<br />
o.close()<br />
f.close()<br />

发表评论

电子邮件地址不会被公开。 必填项已用*标注

This site uses Akismet to reduce spam. Learn how your comment data is processed.