forked from te4-Leo-Wahlandt/PythonOpenCVExamen
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrapper.py
More file actions
35 lines (31 loc) · 978 Bytes
/
scrapper.py
File metadata and controls
35 lines (31 loc) · 978 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import requests
import re
from bs4 import BeautifulSoup
from urllib.parse import unquote
import RPi.GPIO as GPIO
baseURL = 'https://biluppgifter.se/fordon/'
def CheckifPolice(result):
r = requests.get(baseURL+result)
soup = BeautifulSoup(r.text, 'html.parser')
if(soup.find_all('div', {'class': 'alert alert-danger text-center'})):
print("Polis")
GPIO.setup(6, True)
else:
print("Ingen Polis")
getInfo = soup.find('a', {'class': 'gtm-merinfo'})
href = getInfo['href']
getDriver(href)
GPIO.setup(26, True)
def getDriver(getInfo):
splitURL = getInfo.split('/')
if(splitURL[3] == 'foretag'):
print("Ägs av företaget: " + splitURL[4])
else:
nameAndYear = splitURL[5].split('-')
fullName = ""
for name in nameAndYear[0:-1]:
fullName += name + " "
year = nameAndYear[-1]
print(fullName)
print(year)
CheckifPolice('AAS23A')