-4

im trying to get proxies out of a web page

import urllib
import re
myfile = open("C:\\Users\Teli\Desktop\pro.txt", "w")
page = urllib.urlopen("http://www.samair.ru/proxy/ip-address-01.htm").read()
a = re.findall('\d+\.\d+\.\d+\.\d+', page)
myfile.write(str(a))
myfile.close()

why does it say:

page = urllib.urlopen("http://www.samair.ru/proxy/ip-address-01.htm").read()

AttributeError: 'module' object has no attribute 'urlopen'
4

2 回答 2

0

我使用了python2.7并且它有效

import urllib
import re
myfile = open("C:\\Users\Teli\Desktop\pro.txt", "w")
pagea = urllib.urlopen("http://www.samair.ru/proxy/ip-address-01.htm").read()
a = re.findall('\d+\.\d+\.\d+\.\d+', pagea)
pageb = urllib.urlopen("http://www.samair.ru/proxy/ip-address-02.htm").read()
b = re.findall('\d+\.\d+\.\d+\.\d+', pageb)
pagec = urllib.urlopen("http://www.samair.ru/proxy/ip-address-03.htm").read()
c = re.findall('\d+\.\d+\.\d+\.\d+', pagec)
paged = urllib.urlopen("http://www.samair.ru/proxy/ip-address-04.htm").read()
d = re.findall('\d+\.\d+\.\d+\.\d+', paged)
myfile.write(str(a)) myfile.write(str(b)) myfile.write(str(c))
myfile.write(str(d)) myfile.close()
于 2013-04-29T17:38:48.560 回答
0

您正在使用 python 3 或urllib.py在当前目录中有一个名为的文件。

于 2013-04-28T21:20:58.563 回答