本文整理汇总了Python中utils.get_url函数的典型用法代码示例。如果您正苦于以下问题:Python get_url函数的具体用法?Python get_url怎么用?Python get_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get_url函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: get_offices
def get_offices(self):
points = []
point = Point()
point.prov = self.uid
point.type = TYPE_OFFICE
point.name = u'Головное отделение'
point.address = u'г. Минск, ул. Некрасова, 114'
point.lat = 53.940182
point.lng = 27.56712
point.phones = [u'88011006000']
point.time = u'пн-чт: 09.00-17.00, перерыв: 13.00-13.50, пт и предпраздничные дни: 09.00-16.00, перерыв: 13.00-13.40, сб, вс: выходные'
point.check_coordinates = CHECK_OFFICIAL
point.check_information = CHECK_OFFICIAL
points.append(point)
page = PQ(get_url(self.__parse_data_office_cbu_url))
for item in map(PQ, page('.itemFilial')):
point = self.__parse_office(item)
if point:
points.append(point)
page = PQ(get_url(self.__parse_data_office_retail_url))
for item in map(PQ, page('.itemFilial')):
point = self.__parse_office(item)
if point:
points.append(point)
return points
开发者ID:tbicr,项目名称:BankParsers,代码行数:28,代码来源:credex.py
示例2: makeChapters
def makeChapters(self):
log.debug("makeChapters")
for chapter in self.chapters:
log.debug("make Pages for chapter %s" % chapter.number)
c = utils.checkChapterDir(self.basedir, self.title, chapter.number)
if c != 0 and self.action == "append" and \
self.what_chapter == "all":
continue
try:
soup = BS(utils.get_url(chapter.url, self.lookups).read())
except KeyError as e:
log.debug("KeyError %s, adding to lookups" % e)
self.addLookup(chapter.url)
log.debug("Retrying...")
soup = BS(utils.get_url(chapter.url, self.lookups).read())
for page in soup.find_all('a'):
if "Last Page" in page.get_text():
log.debug(page.get('href'))
lastpage = page.get_text().rstrip(')').split('(')[-1]
baseurl = page.get('href')
for numPage in range(0, int(lastpage)):
number = numPage + 1
url = "%s/%d" % (baseurl, number)
Page = manga.Page(utils.unifyNumber(number), url)
chapter.Pages.append(Page)
self.downloadBook()
开发者ID:krilyat,项目名称:MangaDownloader,代码行数:27,代码来源:Mangastream.py
示例3: get_offices
def get_offices(self):
points = []
items_tree = ET.fromstring(get_url(self.__offices_xml_url))
for item in items_tree.iter('item'):
point = self.__parse_office(item)
if point:
points.append(point)
page = PQ(get_url(self.__regional_offices_page_url))
point = None
for item in map(PQ, page('#content_internal span:eq(0)').children()):
if item[0].tag not in self.__regional_offices_tags:
continue
if item[0].tag == 'h2':
point = Point()
point.prov = self.uid
point.type = TYPE_OFFICE
point.name = trim_spaces_and_commas(normalize_text(item.text()))
point.check_information = CHECK_OFFICIAL
continue
if not point:
continue
item_html = replace_br(item.html(), ';;;')
sub_items = PQ(item_html).text().split(';;;')
point.address, point.place = split_address_place(sub_items[0])
for sub_item in map(normalize_text, sub_items[1:]):
if sub_item.startswith(u'т.ф.:'):
point.phone = normalize_phones(sub_item[len(u'т.ф.:'):].split(','))
warning_not_official_coordinates(point)
points.append(point)
point = None
return points
开发者ID:umax,项目名称:BankParsers,代码行数:31,代码来源:bsb.py
示例4: login
def login():
'''
Handle user logins.
'''
now = datetime.now()
launch = datetime(2016, 3, 28, 19, 30, 0)
begin = now >= launch
print(launch, now)
if begin is False:
return redirect('/')
if request.method == "POST":
username = request.form.get('username').strip()
password = request.form.get('password').strip()
if validate_user(database, username, password):
auth_user = User(username)
login_user(auth_user)
user_level = get_level(database, current_user.id)
return redirect(get_url(database, user_level))
else:
return render_template('login.html', force=False, error=True)
else:
if current_user.is_authenticated:
user_level = get_level(database, current_user.id)
resume = get_url(database, user_level)
return render_template('login.html', force=True,
username=current_user.id, error=False,
resume=resume)
return render_template('login.html', force=False, error=None)
开发者ID:clickyotomy,项目名称:mindsweeper-v5,代码行数:32,代码来源:server.py
示例5: get_offices
def get_offices(self):
points = []
offices_page = PQ(get_url(self.__parse_data_offices_url))
for office_item in map(PQ, offices_page('.office a')):
url = self.site + office_item.attr('linkoffice')
page = PQ(get_url(url))
point = self.__parse_office(page('#body'))
if point:
points.append(point)
return points
开发者ID:tbicr,项目名称:BankParsers,代码行数:10,代码来源:trust.py
示例6: test_get_url
def test_get_url(self):
data = {
'1-MMN-150': 'https://sluzby.fmph.uniba.sk/infolist/SK/1-MMN-150.html',
'1-MAT-150': 'https://sluzby.fmph.uniba.sk/infolist/SK/1-MAT-150.html'
}
for in_data, out_data in data.iteritems():
self.assertEqual(utils.get_url(in_data, lang='sk'), out_data)
self.assertFalse(utils.get_url('asdf', lang='es'))
self.assertFalse(utils.get_url(''))
开发者ID:fmfi-svt,项目名称:ais-infolisty,代码行数:11,代码来源:test_utils.py
示例7: test_get_url
def test_get_url(self):
data = {
'1-MMN-150': self.add_base_url('1-MMN-150.html'),
'1-MAT-150': self.add_base_url('1-MAT-150.html')
}
for in_data, out_data in data.iteritems():
self.assertEqual(utils.get_url(in_data, lang='sk'), out_data)
self.assertFalse(utils.get_url('asdf', lang='es'))
self.assertFalse(utils.get_url(''))
开发者ID:crnkjck,项目名称:ais-infolisty,代码行数:11,代码来源:test_utils.py
示例8: get_offices
def get_offices(self):
points = []
cities = self.__get_cities(self.__cities_offices_list_url)
for city_id, param_iblock_id, param_balun_name, city_name in cities:
city_page = PQ(get_url(self.__list_offices_url_template.format(city_id)))
for item in map(PQ, city_page('.content_table table tbody tr.first_td')):
item_id = item('td:eq(0) a').attr('id').replace('office', '')
item_data_url = self.__parse_data_office_url_template.format(item_id, param_iblock_id, param_balun_name)
data_page = PQ(get_url(item_data_url).decode('utf8'))
point = self.__parse_office(data_page, city_name)
if point:
points.append(point)
return points
开发者ID:umax,项目名称:BankParsers,代码行数:13,代码来源:belros.py
示例9: get_terminals
def get_terminals(self):
points = []
country_page = PQ(get_url(self.__terminal_search_url))
for item in map(PQ, country_page('.content select:eq(1) option:gt(0)')):
input2_value = urllib.quote(item.attr('value').encode('cp1251'))
region_url = self.__terminal_search_url + '&input2=' + input2_value
region_page = PQ(get_url(region_url))
for item in map(PQ, region_page('.content select:eq(2) option:gt(0)')):
input3_value = urllib.quote(item.attr('value').encode('cp1251'))
city_page = PQ(get_url(region_url + '&input3=' + input3_value))
for item in map(PQ, city_page('.content .solid_table tr:gt(0)')):
point = self.__parse_terminal(item)
if point:
points.append(point)
return points
开发者ID:tbicr,项目名称:BankParsers,代码行数:15,代码来源:belarus.py
示例10: get_atms
def get_atms(self):
points = []
coordinates = {}
coordinates_tree = ET.fromstring(get_url(self.__atms_xml_coordinates_url))
for item in coordinates_tree.iter('item'):
terminal_id = item.find('terminal_id').text
lat = item.find('lattitude').text
lng = item.find('longitude').text
coordinates[terminal_id] = (lat, lng)
items_tree = ET.fromstring(get_url(self.__atms_xml_url))
for item in items_tree.iter('item'):
point = self.__parse_atm(item, coordinates)
if point:
points.append(point)
return points
开发者ID:umax,项目名称:BankParsers,代码行数:15,代码来源:bsb.py
示例11: make_list
def make_list(url):
params = utils.get_url(url)
try:
# Show a dialog
pDialog = xbmcgui.DialogProgress()
pDialog.create('Unofficial AFL Video', 'Fetching match list')
# Temporary until we tag our match videos with the match id
if params.has_key('match'):
videos_url = config.MATCH_URL % params['match']
else:
videos_url = config.VIDEOS_URL + url + '&output=json'
programs = comm.fetch_videos(videos_url)
# fill media list
ok = fill_media_list(programs)
except:
# oops print error message
print "ERROR: %s (%d) - %s" % (sys.exc_info()[2].tb_frame.f_code.co_name, sys.exc_info()[2].tb_lineno, sys.exc_info()[1])
ok = False
# send notification we're finished, successfully or unsuccessfully
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
开发者ID:andybotting,项目名称:afl-video,代码行数:25,代码来源:videos.py
示例12: make_programs_list
def make_programs_list(url):
try:
params = utils.get_url(url)
programs = comm.get_series_from_feed(params['series'], category=params['category'])
ok = True
for p in programs:
listitem = xbmcgui.ListItem(label=p.get_list_title(), iconImage=p.get_thumbnail(), thumbnailImage=p.get_thumbnail())
listitem.setInfo('video', p.get_xbmc_list_item())
listitem.setProperty('IsPlayable', 'true')
if hasattr(listitem, 'addStreamInfo'):
listitem.addStreamInfo('audio', p.get_xbmc_audio_stream_info())
listitem.addStreamInfo('video', p.get_xbmc_video_stream_info())
# Build the URL for the program, including the list_info
url = "%s?play=true&%s" % (sys.argv[0], p.make_xbmc_url())
# Add the program item to the list
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False, totalItems=len(programs))
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
except:
utils.handle_error('Unable to fetch program list')
开发者ID:primaeval,项目名称:xbmc-addon-abc-iview,代码行数:25,代码来源:programs.py
示例13: make_series_list
def make_series_list(url):
params = utils.get_url(url)
try:
iview_config = comm.get_config()
series_list = comm.get_programme(iview_config, params["category_id"])
series_list.sort()
ok = True
for s in series_list:
url = "%s?series_id=%s" % (sys.argv[0], s.id)
thumbnail = s.get_thumbnail()
listitem = xbmcgui.ListItem(s.get_list_title(), iconImage=thumbnail, thumbnailImage=thumbnail)
listitem.setInfo('video', { 'plot' : s.get_description() })
# add the item to the media list
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=True)
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
xbmcplugin.setContent(handle=int(sys.argv[1]), content='tvshows')
except:
d = xbmcgui.Dialog()
message = utils.dialog_error("Unable to fetch listing")
d.ok(*message)
utils.log_error();
开发者ID:darren-rogan,项目名称:xbmc-addon-abc-iview,代码行数:26,代码来源:series.py
示例14: play
def play(params):
__addon__ = xbmcaddon.Addon()
p = utils.get_url(params)
# Show a dialog
d = xbmcgui.DialogProgress()
d.create(config.NAME, "Starting %s..." % p['name'])
try:
thumb = os.path.join(__addon__.getAddonInfo('path'), "resources", "img", "%s.jpg" % p['id'])
labels = {
"title": p['name'],
"artist": "AFL Radio",
"genre": "Sport"
}
listitem = xbmcgui.ListItem(p['name'])
listitem.setInfo(type='music', infoLabels=labels)
listitem.setThumbnailImage(thumb)
# PAPlayer or AUTO fails here for some absurd reason
xbmc.Player(xbmc.PLAYER_CORE_DVDPLAYER).play(p['url'], listitem)
except:
# user cancelled dialog or an error occurred
d = xbmcgui.Dialog()
message = utils.dialog_error("Unable to play %s" % p['name'])
d.ok(*message)
utils.log_error();
开发者ID:vu-au,项目名称:xbmc-addon-afl-radio,代码行数:28,代码来源:play.py
示例15: __get_points
def __get_points(self, id, parse_point):
points = []
page = PQ(get_url(self.__points_data_url_template.format(id)))
paging_urls = []
for item in map(PQ, page("form[name=fcatalog] .nopt a")):
url = item.attr("href")
paging_urls.append(self.site + url)
paging_urls = [page] + list(set(paging_urls))
for page in paging_urls:
if type(page) == str:
page = PQ(get_url(page))
for item in map(PQ, page("form[name=fcatalog] #catalog tr:gt(0)")):
point = parse_point(item)
if point:
points.append(point)
return points
开发者ID:tbicr,项目名称:BankParsers,代码行数:16,代码来源:alfa.py
示例16: __get_regions_ids
def __get_regions_ids(self, url):
ids = []
page = PQ(get_url(url))
for item in map(PQ, page('.top_block_menu .region a')):
id = item.attr('href').replace('section.php?SECTION_ID=', '')
ids.append(id)
return ids
开发者ID:umax,项目名称:BankParsers,代码行数:7,代码来源:belinvest.py
示例17: makePages
def makePages(self):
log.debug("makePages")
for chapter in self.chapters:
log.debug("make Pages for chapter %s" % chapter.number)
c = utils.checkChapterDir(self.basedir, self.title, chapter.number)
if c != 0 and self.action == "append" and \
self.what_chapter == "all":
continue
soup = BS(utils.get_url("%s%s%s" % (self.baseurl, chapter.url,
self.suffix),
self.lookups).read())
for image in soup.find_all('img'):
image_url = image.get('src')
if "manga-img" in image_url:
img_host = image_url.split('/', 3)[-2]
if img_host not in self.lookups:
self.lookups[img_host] = dnslookup(img_host, 'A')[0]
image_url = image_url.replace(img_host,
self.lookups[img_host])
image_ext = image_url.rsplit('.', 1)[-1]
last_page_number = 0
if len(chapter.Images):
last_page_number = int(chapter.Images[-1].number
.split('.')[0]) + 1
i = manga.Image(utils.pageNumber(image_url,
last_page_number),
image_url, img_host, image_ext)
chapter.Images.append(i)
sorted(chapter.Images, key=lambda img: img.number)
self.downloadBook()
开发者ID:krilyat,项目名称:MangaDownloader,代码行数:32,代码来源:Starkana.py
示例18: make_programs_list
def make_programs_list(url):
try:
params = utils.get_url(url)
iview_config = comm.get_config()
programs = comm.get_series_items(iview_config, params["series_id"])
ok = True
for p in programs:
listitem = xbmcgui.ListItem(label=p.get_list_title(), iconImage=p.get_thumbnail(), thumbnailImage=p.get_thumbnail())
listitem.setInfo('video', p.get_xbmc_list_item())
if hasattr(listitem, 'addStreamInfo'):
listitem.addStreamInfo('audio', p.get_xbmc_audio_stream_info())
listitem.addStreamInfo('video', p.get_xbmc_video_stream_info())
# Build the URL for the program, including the list_info
url = "%s?play=true&%s" % (sys.argv[0], p.make_xbmc_url())
# Add the program item to the list
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False, totalItems=len(programs))
xbmcplugin.endOfDirectory(handle=int(sys.argv[1]), succeeded=ok)
xbmcplugin.setContent(handle=int(sys.argv[1]), content='episodes')
except:
d = xbmcgui.Dialog()
msg = utils.dialog_error("Unable to fetch listing")
d.ok(*msg)
utils.log_error();
开发者ID:adammw,项目名称:xbmc-addon-abc-iview,代码行数:29,代码来源:programs.py
示例19: parse_xbmc_url
def parse_xbmc_url(self, string):
""" Takes a string input which is a URL representation of the
program object
"""
d = utils.get_url(string)
if d.has_key("id"):
self.id = d["id"]
if d.has_key("title"):
self.title = d["title"]
if d.has_key("episode_title"):
self.episode_title = d["episode_title"]
if d.has_key("description"):
self.description = d["description"]
if d.has_key("duration"):
self.duration = d["duration"]
if d.has_key("category"):
self.category = d["category"]
if d.has_key("rating"):
self.rating = d["rating"]
if d.has_key("date"):
timestamp = time.mktime(time.strptime(d["date"], "%d/%m/%Y %H:%M:%S"))
self.date = datetime.date.fromtimestamp(timestamp)
if d.has_key("thumbnail"):
self.thumbnail = urllib.unquote_plus(d["thumbnail"])
if d.has_key("url_path"):
self.url_path = d["url_path"]
开发者ID:boggob,项目名称:bogs-xbmc-addons,代码行数:27,代码来源:classes.py
示例20: __get_offices
def __get_offices(self, url, city_name=''):
points = []
page = PQ(get_url(url).decode('utf8'))
time = None
for item in map(PQ, page('#oo__content_value table tr:gt(0)')):
if item('td').attr('colspan') == '3':
continue
point = Point()
point.prov = self.uid
point.type = TYPE_OFFICE
point.name = normalize_text(item('td:eq(0)').text())
point.address = normalize_address(city_name + item('td:eq(1) p:eq(0)').text())
place = item('td:eq(1) p:eq(2)').text()
if not place:
place = item('td:eq(1) p:eq(1)').text()
if place:
point.place = normalize_text(place)
new_time = item('td:eq(2)').text()
if new_time:
time = new_time
point.time = normalize_time(time)
point.check_information = CHECK_OFFICIAL
if point.address in self.__addresses:
point.lat, point.lng = self.__addresses[point.address]
point.check_coordinates = CHECK_OFFICIAL
else:
warning_not_official_coordinates(point)
points.append(point)
return points
开发者ID:tbicr,项目名称:BankParsers,代码行数:29,代码来源:bnb.py
注:本文中的utils.get_url函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论