Automatically Check Delivery Boxes & Electric Bike Availability with Python! An Introduction to Web Scraping

Since it’s a hassle to access the website every time to check, let’s create a Python script to check the real-time inventory of FullTime System (rental bicycles / delivery boxes, etc.).


Prerequisites and Legal Considerations

  • Set up the Python environment (install requests and BeautifulSoup4)

  • Check robots.txt, meta robots tags, and terms of service in advance to confirm scraping permission
    This is important

  • Leave intervals between requests to reduce server load


Script (Fetching Remaining Units)

import requests
from bs4 import BeautifulSoup

def fetch_remaining_bikes(url):
    resp = requests.get(url)
    resp.raise_for_status()  # Error check

    soup = BeautifulSoup(resp.text, "html.parser")

    # Look for a structure like <td class="count">5</td>
    # Use find_all if there are multiple facilities
    td = soup.find("td", class_="count")
    if not td:
        raise ValueError("Could not find the element for remaining units")

    count_text = td.get_text(strip=True)
    try:
        return int(count_text)
    except ValueError:
        raise ValueError(f"Failed to convert to number: {count_text!r}")

if __name__ == "__main__":
    url = "https://f-cs.jp/wcsv2/index.php?id=<DeliveryBoxID>"
    try:
        remaining = fetch_remaining_bikes(url)
        print(f"Remaining electric bikes: {remaining}")
    except Exception as e:
        print(f"An error occurred: {e}")

 

  • requests + BeautifulSoup

  • Since it depends on the HTML structure, you need to verify the class names and other details of the target to be scraped

  • Example Execution Result
    Remaining electric bikes: 7

Conclusion

  • Verify access permissions via robots.txt and meta tags

  • Explicitly specify User-Agent in the request headers

  • Keep appropriate intervals between requests to avoid overloading