Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_info():
- holder = []
- problem_dict = {}
- selection_container = []
- for moselect in base_page.find_all('div', attrs={'class': 'Moselect'}):
- if moselect.find('div', attrs={'id': 'noSize'}):
- holder.append(moselect.find_all('div')[1:])
- for held_item in holder[0]:
- if held_item.find_all('option')[1:]:
- for m in held_item.find_all('option')[1:]:
- append_dict(selection_container, m)
- if len(m.text.split(' ')) > 1:
- stock_info = {
- 'message': reduce(lambda x, y: x + ' ' + y, m.text.split(' ')[1:])[1:-1],
- 'status': 'pre-order'
- }
- problem_dict.update({'stock': stock_info})
- else:
- for m in held_item.find_all('option'):
- append_dict(selection_container, m)
- if len(m.text.split(' ')) > 1:
- stock_info = {
- 'message': reduce(lambda x, y: x + ' ' + y, m.text.split(' ')[1:])[1:-1],
- 'status': 'pre-order'
- }
- problem_dict.update({'stock': stock_info})
- problem_dict.update(dict(selections=selection_container))
- return problem_dict
- problem_dict = {'selection': [{'key': 'value'},{'key': 'value'},]}
- problem_dict = {'selection': [{'key': 'value'},{'key': 'value'}], 'stock': {'key': 'value', 'key': 'value'} }
- if held_item.find_all('option')[1:]:
- ...
- else:
- ...
- options = held_item.find_all('option')
- if len(options) > 1:
- options.pop(0)
- for option in options:
- append_dict(selection_container, option)
- # If there is a non-zero amount of spaces, there will be at least
- # 2 partitions when split.
- if option.text.count(' '):
- stock_info = {'message': reduce(lambda x, y: x + ' ' + y, option.text.split(' ')[1:])[1:-1],
- 'status': 'pre-order'}
- problem_dict.update({'stock': stock_info})
- stock_info = {
- 'message': reduce(lambda x, y: x + ' ' + y, m.text.split(' ')[1:])[1:-1],
- 'status': 'pre-order'
- }
- stock_info = {'message': reduce(lambda x, y: x + ' ' + y, m.text.split(' ')[1:])[1:-1],
- 'status': 'pre-order'}
- stock_info = {'message': m.split(' ', 1)[-1][1:-1] ...
- # Below is reduced version of:
- # m[m.index(' ') + 1:][1:-1]
- stock_info = {'message': m[m.index(' ') + 2:-1] ...
- holder = [moselect.find_all('div')[1:]
- for moselect in base_page.find_all('div', attrs={'class': 'Moselect'})
- if moselect.find('div', attrs={'id': 'noSize'})]
- def get_info():
- problem_dict = {}
- selection_container = []
- holder = [moselect.find_all('div')[1:]
- for moselect in base_page.find_all('div', attrs={'class': 'Moselect'})
- if moselect.find('div', attrs={'id': 'noSize'})]
- for held_item in holder[0]:
- options = held_item.find_all('option')
- if len(options) > 1:
- options.pop(0)
- for option in options:
- append_dict(selection_container, option)
- # If there is a non-zero amount of spaces, there will be at least
- # 2 partitions when split.
- if option.text.count(' '):
- stock_info = {'message': {'message': m[m.index(' ') + 2:-1],
- 'status': 'pre-order'}
- problem_dict.update({'stock': stock_info})
- problem_dict.update(dict(selections=selection_container))
- return problem_dict
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement