-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fb18bdc
commit f28c8b9
Showing
5 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# The MIT License (MIT) | ||
|
||
Copyright (c) 2016 Obi Uchenna David <[email protected]> | ||
|
||
> Permission is hereby granted, free of charge, to any person obtaining a copy | ||
> of this software and associated documentation files (the "Software"), to deal | ||
> in the Software without restriction, including without limitation the rights | ||
> to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
> copies of the Software, and to permit persons to whom the Software is | ||
> furnished to do so, subject to the following conditions: | ||
> | ||
> The above copyright notice and this permission notice shall be included in | ||
> all copies or substantial portions of the Software. | ||
> | ||
> THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
> IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
> FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
> AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
> LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
> OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
> THE SOFTWARE. | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
#!/usr/bin/env python | ||
# -*- coding: utf-8 -*- | ||
|
||
__author__ = 'othreecodes' | ||
|
||
import requests | ||
from bs4 import BeautifulSoup | ||
BASE_URL = 'http://www.lsmvaapvs.org' | ||
import re | ||
from errors import errors | ||
|
||
def parse_response(response): | ||
soup = BeautifulSoup(response.text,"html.parser") | ||
try: | ||
data = soup.find_all('td') | ||
except: | ||
raise errors.InvalidPlateError | ||
|
||
|
||
'''Cleaning the HTML tags from the string''' | ||
for i in range(0,len(data)): | ||
data[i] = clean_html_tags(str(data[i])) | ||
|
||
'''Turning the list into a dict''' | ||
data_dict = dict(zip(*[iter(data)] * 2)) | ||
return data_dict | ||
|
||
|
||
'''Clean the HTML tags from response''' | ||
def clean_html_tags(raw_html): | ||
clean = re.compile('<.*?>') | ||
clean_text = re.sub(clean, '', raw_html) | ||
return clean_text | ||
|
||
'''MVRD class''' | ||
class Mvrd: | ||
def __init__(self,plate_number): | ||
self.plate_number = plate_number | ||
|
||
'''Getting the raw html from www.lsmvaapvs.org''' | ||
def get_data(self): | ||
response = requests.get(BASE_URL+'/search.php',{'vpn':self.plate_number}) | ||
data = parse_response(response=response) | ||
return data | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Mvrd(Exception): | ||
''' | ||
MVRD Exception | ||
''' | ||
pass | ||
|
||
class InvalidPlateError(Exception): | ||
''' | ||
The Plate number Entered was Invalid | ||
''' | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
[metadata] | ||
description-file = README.md |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
from distutils.core import setup | ||
setup( | ||
name = 'pymvrd', | ||
packages = ['pymvrd'], | ||
version = '0.1', | ||
description = 'Motor Vehicle Registration Information Search Portal Library', | ||
author = 'Obi Uchenna David', | ||
author_email = '[email protected]', | ||
url = 'https://github.com/othreecodes/pymvrd', | ||
download_url = 'https://github.com/othreecodes/pymvrd/tarball/0.1', | ||
keywords = ['vehicle','plate number','registration'], | ||
classifiers = [], | ||
) |