-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscrape-details.py
More file actions
45 lines (33 loc) · 990 Bytes
/
scrape-details.py
File metadata and controls
45 lines (33 loc) · 990 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
36
37
38
39
40
41
42
43
44
45
import requests
import argparse
from bs4 import BeautifulSoup
url = 'https://secdim.com/defensive-cloud-native-app/'
# Send a GET request to the URL
response = requests.get(url)
# Parse the HTML content using BeautifulSoup
soup = BeautifulSoup(response.content, 'html.parser')
# Find the title tag and extract its text
title = soup.find('title').get_text()
print(f"Title: {title}")
print("")
# Find all label elements whose 'for' attribute starts with 'date'
date_labels = soup.select('label[for^="date"]')
print("Found Dates:")
dates = []
for label in date_labels:
date = label.text.replace('\n', '')
dates.append(date)
print(dates)
booked_out_dates = soup.find_all('s')
print("")
print("Booked out dates:")
out_dates = []
for booked_out_date in booked_out_dates:
out_date = booked_out_date.text
out_dates.append(out_date)
print(out_dates)
print("")
if date not in out_dates:
print(f"{date} appears to be available")
else:
print(f"{date} is booked out")