Last active
August 29, 2015 14:12
-
-
Save apalii/e2dffa5bc4b8feb691e0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
from bs4 import BeautifulSoup as bs | |
import sys | |
def get_track_status(track_number): | |
base_url = 'http://novaposhta.ua/ru/tracking/?cargo_number=' | |
headers = {'Accept-Language':'ru-RU,ru;q=0.8,en-US;q=0.5,en;q=0.3'} | |
data = requests.get(base_url + track_number, headers=headers) | |
data.encoding = 'utf-8' | |
soup = bs(data.text) | |
soup_status = soup.find_all('strong')[1].next_sibling | |
status = soup_status.strip().split() | |
return '{} - {}'.format(status[0],status[1]) | |
if __name__ == "__main__": | |
if len(sys.argv) == 1: | |
print('Enter track id') | |
else: | |
print(get_track_status(sys.argv[1])) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment