Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python2
- # -*- coding: utf-8 -*-
- from BeautifulSoup import BeautifulSoup
- import sys
- import urllib
- import re
- SEARCH_QUERY = "http://zakupki.gov.ru/pgz/public/action/search/simple/run?orderName={}"
- LINK_REGEX = r"/pgz/public/action/orders/info/common_info/show\?notificationId=(\d+)"
- NOTIFICATION_PAGE = "http://zakupki.gov.ru/pgz/public/action/orders/info/common_info/show?notificationId={}"
- CHEAT_CANDIDATES = ['нa', 'нe', 'пo', 'нy']
- def get_search_results(query):
- link = SEARCH_QUERY.format(query)
- soup = BeautifulSoup(urllib.urlopen(link))
- container = soup.find(id = "searchResultContainer")
- items = container.findAll('a', {'class': "iceOutLnk"})
- result = []
- for item in items:
- notification_id = re.search(LINK_REGEX, str(item)).group(1)
- result.append(NOTIFICATION_PAGE.format(notification_id))
- return result
- result = []
- for query in CHEAT_CANDIDATES:
- result.extend(get_search_results(query))
- result = sorted(list(set(result))) # making links unique
- for link in result:
- print(link)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement