本文整理匯總了Python中urllib.URLopener.readlines方法的典型用法代碼示例。如果您正苦於以下問題:Python URLopener.readlines方法的具體用法?Python URLopener.readlines怎麽用?Python URLopener.readlines使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類urllib.URLopener
的用法示例。
在下文中一共展示了URLopener.readlines方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。
示例1: URLopener
# 需要導入模塊: from urllib import URLopener [as 別名]
# 或者: from urllib.URLopener import readlines [as 別名]
generated content
""" % sys.argv[0]
sys.exit(1)
elif opt == '-o':
output = arg
except GetoptError:
print "Wrong parameters. type %s -h for usage" % sys.argv[0]
sys.exit(2)
# Richiesta del file con l'elenco insegnanti
print "Reading people..."
names = URLopener().open("%s://%s/%s/docenti.htm" % (URL_PROTOCOL, URL_DOMAIN, URL_SUBPATH))
# foreach insegnante
courses = []
for line in names.readlines():
key = re.sub("\<\/?[a-zA-Z]+([ a-zA-Z]+\=\"[\S]*\")*\>|\n", "", line)
value = re.match("(.*)href\=\"(?P<url>[\S]*)\"(.*)", line).group('url')
# richiedi la pagina insegnante
print "Retrieve %s..." % value
course = URLopener().open("%s://%s/%s/%s" % (URL_PROTOCOL, URL_DOMAIN, URL_SUBPATH, value))
parser = TTParser(key)
# parsing orario, corso
parser.feed(course.read())
courses.extend(parser.get_list())
# inserimento in current.gap
print "Generation complete. Writing on %s..." % output
out = file(output, 'w')
for c in courses:
示例2: get_facilities
# 需要導入模塊: from urllib import URLopener [as 別名]
# 或者: from urllib.URLopener import readlines [as 別名]
def get_facilities(file):
o = URLopener().open(file)
t = o.readlines()
o.close()
return [i.split(' ')[0].lower() for i in t]