-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmain.py
executable file
·51 lines (42 loc) · 1.44 KB
/
main.py
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#!/usr/bin/env python3
import argparse
from bieniciscraper.scraper import scrape
from bieniciscraper.constants import MIN_LIMIT_VAL, MAX_LIMIT_VAL
def range_limited_integer_type(arg):
try:
f = int(arg)
except ValueError:
raise argparse.ArgumentTypeError("must be an integer")
if f < MIN_LIMIT_VAL or f > MAX_LIMIT_VAL:
raise argparse.ArgumentTypeError("must be < " + str(MAX_LIMIT_VAL) + " and > " + str(MIN_LIMIT_VAL))
return f
def main():
parser = argparse.ArgumentParser(description='bienici listings scraper')
parser.add_argument(
'-u',
'--url',
type=str,
required=False,
default='https://www.bienici.com/recherche/achat/france/chateau',
help='url to scrape the listings from — by default https://www.bienici.com/recherche/achat/france/chateau'
)
parser.add_argument(
'-l',
'--limit',
type=range_limited_integer_type,
required=False,
default=100,
help='maximum number of listings to scrape — by default 100'
)
parser.add_argument(
'-o',
'--output',
type=str,
required=False,
default='data_bienici_lobstr_io.csv',
help='filename to save the results — by default data_bienici_lobstr_io.csv'
)
args = parser.parse_args()
scrape(url=args.url, limit=args.limit, output=args.output)
if __name__ == '__main__':
main()