diff --git a/README.md b/README.md index 6341be6..5fdbeb0 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ A Python bot for Day 47 of Udemy's "100 Days of Code: The Complete Python Pro Bo ## 馃Л Overview -The assignment is built in four lecture steps. Each step was delivered on its own branch and pull request, and each has a screenshot and a wiki page in English, Danish and Bahasa Malaysia that explains what it teaches. +The assignment is built in four lecture steps. Each step was delivered on its own branch and pull request, and each has a screenshot and a [wiki](#-links) page in English, Danish and Bahasa Malaysia that explains what it teaches. | Step | What it adds | Status | | --- | --- | --- | @@ -163,6 +163,7 @@ GNU Affero General Public License v3.0, see [LICENSE](LICENSE). - [Repository][repository] - [Documentation][documentation] - [Issue tracker][issues] +- [Wiki in English, Danish and Bahasa Malaysia][wiki] (what we gained in each lecture step; the pages are in [`docs/wiki/`](docs/wiki/)) ## 馃搸 Appendix: Project documents @@ -184,6 +185,7 @@ The documents a newcomer needs, in reading order. [repository]: https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker [documentation]: ./docs/ [issues]: https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/issues +[wiki]: https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/wiki [agents]: ./AGENTS.md [BC-001]: ./docs/business-case.md [SA-001]: ./docs/stakeholder-analysis.md diff --git a/docs/wiki/Home-da.md b/docs/wiki/Home-da.md new file mode 100644 index 0000000..fe09ae8 --- /dev/null +++ b/docs/wiki/Home-da.md @@ -0,0 +1,14 @@ +# Amazon Price Tracker + +馃寪 [English](Home) 路 **Dansk** 路 [Bahasa Melayu](Home-ms) + +En Python-bot til dag 47 af Udemys "100 Days of Code: The Complete Python Pro Bootcamp". Den l忙ser en produktside, finder prisen og sender en e-mail, n氓r prisen er under en m氓lpris. Opgaven har fire trin; hvert trin har en side her med det, vi byggede, et sk忙rmbillede og **det, vi l忙rte**. + +| Trin | Side | Det vi l忙rte | +| --- | --- | --- | +| 1 | [Find prisen](Step-1-Scrape-the-Price-da) | At l忙se HTML med BeautifulSoup og g酶re `$99.99` til et decimaltal | +| 2 | [E-mail-alarm](Step-2-Email-Alert-da) | At sende mail med `smtplib` og holde hemmeligheder i `.env` | +| 3 | [Request headers](Step-3-Request-Headers-da) | Hvorfor et script skal ligne en browser | +| 4 | [Live Amazon-side](Step-4-Live-Amazon-da) | Hvad der sker p氓 et rigtigt websted, og hvordan man fejler tydeligt | + +K酶r den: se [README](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker#-setup) (virtuelt milj酶, `python -m pip install --upgrade pip`, `.env`). Kode, plan og reviews: [repository](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker). diff --git a/docs/wiki/Home-ms.md b/docs/wiki/Home-ms.md new file mode 100644 index 0000000..8836a33 --- /dev/null +++ b/docs/wiki/Home-ms.md @@ -0,0 +1,14 @@ +# Amazon Price Tracker + +馃寪 [English](Home) 路 [Dansk](Home-da) 路 **Bahasa Melayu** + +Bot Python untuk Hari ke-47 kursus Udemy "100 Days of Code: The Complete Python Pro Bootcamp". Ia membaca halaman produk, mengambil harga dan menghantar e-mel apabila harga berada di bawah harga sasaran. Tugasan ini mempunyai empat langkah; setiap langkah ada halaman di sini yang menunjukkan apa yang dibina, tangkapan skrin dan **apa yang kita perolehi**. + +| Langkah | Halaman | Apa yang kita perolehi | +| --- | --- | --- | +| 1 | [Ambil harga](Step-1-Scrape-the-Price-ms) | Membaca HTML dengan BeautifulSoup dan menukar `$99.99` kepada nombor perpuluhan | +| 2 | [Amaran e-mel](Step-2-Email-Alert-ms) | Menghantar e-mel dengan `smtplib` dan menyimpan rahsia dalam `.env` | +| 3 | [Header permintaan](Step-3-Request-Headers-ms) | Mengapa skrip perlu kelihatan seperti pelayar | +| 4 | [Halaman Amazon sebenar](Step-4-Live-Amazon-ms) | Apa yang berlaku di laman sebenar, dan cara gagal dengan jelas | + +Jalankan: lihat [README](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker#-setup) (persekitaran maya, `python -m pip install --upgrade pip`, `.env`). Kod, pelan dan semakan: [repositori](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker). diff --git a/docs/wiki/Home.md b/docs/wiki/Home.md new file mode 100644 index 0000000..94fbd65 --- /dev/null +++ b/docs/wiki/Home.md @@ -0,0 +1,14 @@ +# Amazon Price Tracker + +馃寪 **English** 路 [Dansk](Home-da) 路 [Bahasa Melayu](Home-ms) + +A Python bot for Day 47 of Udemy's "100 Days of Code: The Complete Python Pro Bootcamp". It reads a product page, extracts the price and sends an e-mail when the price is below a target. The assignment has four lecture steps; each has a page here that shows what we built, a screenshot and **what we gained**. + +| Step | Page | What we gained | +| --- | --- | --- | +| 1 | [Scrape the price](Step-1-Scrape-the-Price) | Reading HTML with BeautifulSoup and turning `$99.99` into a float | +| 2 | [E-mail alert](Step-2-Email-Alert) | Sending mail with `smtplib` and keeping secrets in `.env` | +| 3 | [Request headers](Step-3-Request-Headers) | Why a script should look like a browser | +| 4 | [Live Amazon page](Step-4-Live-Amazon) | What happens on a real site, and how to fail clearly | + +Run it: see the [README](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker#-setup) (virtual environment, `python -m pip install --upgrade pip`, `.env`). Code, plan and reviews: [repository](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker). diff --git a/docs/wiki/Step-1-Scrape-the-Price-da.md b/docs/wiki/Step-1-Scrape-the-Price-da.md new file mode 100644 index 0000000..c01007f --- /dev/null +++ b/docs/wiki/Step-1-Scrape-the-Price-da.md @@ -0,0 +1,18 @@ +# Trin 1: find prisen + +馃寪 [English](Step-1-Scrape-the-Price) 路 **Dansk** 路 [Bahasa Melayu](Step-1-Scrape-the-Price-ms) + +**Opgave.** Brug BeautifulSoup til at hente prisen p氓 Instant Pot p氓 酶vesiden som et decimaltal og udskriv den. + +**Det vi byggede.** `get_title(html)` og `get_price(html)` i `infrastructure/scraper.py`. Prisen st氓r i det f酶rste element med klassen `a-offscreen`; teksten er `$99.99`. `split("$")` fjerner valutategnet, og `float()` laver tallet. + +![脴vesiden](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-1-practice-page.png) + +![Botten udskriver titel og pris](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-1-run.png) + +**Det vi l忙rte** + +- At finde et element i browserens inspekt酶r og v忙lge det med BeautifulSoup (`select_one`). +- At rense hentet tekst (`strip`, `split`), f酶r den g酶res til tal med `float()`. +- Tests, der bruger en gemt kopi af siden og derfor k酶rer uden netv忙rk. +- En tydelig fejl (`PriceNotFoundError`), n氓r elementet mangler. diff --git a/docs/wiki/Step-1-Scrape-the-Price-ms.md b/docs/wiki/Step-1-Scrape-the-Price-ms.md new file mode 100644 index 0000000..5478564 --- /dev/null +++ b/docs/wiki/Step-1-Scrape-the-Price-ms.md @@ -0,0 +1,18 @@ +# Langkah 1: ambil harga + +馃寪 [English](Step-1-Scrape-the-Price) 路 [Dansk](Step-1-Scrape-the-Price-da) 路 **Bahasa Melayu** + +**Tugasan.** Gunakan BeautifulSoup untuk mendapatkan harga Instant Pot di halaman latihan sebagai nombor perpuluhan dan cetaknya. + +**Apa yang dibina.** `get_title(html)` dan `get_price(html)` dalam `infrastructure/scraper.py`. Harga berada dalam elemen pertama dengan kelas `a-offscreen`; teksnya `$99.99`. `split("$")` membuang simbol mata wang dan `float()` menghasilkan nombor. + +![Halaman latihan](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-1-practice-page.png) + +![Bot mencetak tajuk dan harga](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-1-run.png) + +**Apa yang kita perolehi** + +- Cara mencari elemen dalam pemeriksa pelayar dan memilihnya dengan BeautifulSoup (`select_one`). +- Cara membersihkan teks yang diambil (`strip`, `split`) sebelum menukarnya dengan `float()`. +- Ujian yang menggunakan salinan halaman yang disimpan, jadi ia berjalan tanpa rangkaian. +- Ralat yang jelas (`PriceNotFoundError`) apabila elemen tiada. diff --git a/docs/wiki/Step-1-Scrape-the-Price.md b/docs/wiki/Step-1-Scrape-the-Price.md new file mode 100644 index 0000000..525f390 --- /dev/null +++ b/docs/wiki/Step-1-Scrape-the-Price.md @@ -0,0 +1,18 @@ +# Step 1: scrape the price + +馃寪 **English** 路 [Dansk](Step-1-Scrape-the-Price-da) 路 [Bahasa Melayu](Step-1-Scrape-the-Price-ms) + +**Assignment.** Use BeautifulSoup to get the price of the Instant Pot on the practice page as a floating point number and print it. + +**What we built.** `get_title(html)` and `get_price(html)` in `infrastructure/scraper.py`. The price is in the first element with class `a-offscreen`; its text is `$99.99`. `split("$")` drops the currency sign and `float()` makes the number. + +![The practice page](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-1-practice-page.png) + +![The bot prints the title and the price](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-1-run.png) + +**What we gained** + +- How to find an element in the browser's inspector and select it with BeautifulSoup (`select_one`). +- How to clean scraped text (`strip`, `split`) before converting it with `float()`. +- Tests that use a saved copy of the page, so they run without the network. +- A clear error (`PriceNotFoundError`) when the element is missing. diff --git a/docs/wiki/Step-2-Email-Alert-da.md b/docs/wiki/Step-2-Email-Alert-da.md new file mode 100644 index 0000000..d535897 --- /dev/null +++ b/docs/wiki/Step-2-Email-Alert-da.md @@ -0,0 +1,20 @@ +# Trin 2: e-mail-alarm + +馃寪 [English](Step-2-Email-Alert) 路 **Dansk** 路 [Bahasa Melayu](Step-2-Email-Alert-ms) + +**Opgave.** N氓r prisen er under en m氓lpris (100), send en e-mail til dig selv med produktets titel, prisen og et link til at k酶be det. Hold e-mailadresse og adgangskode ude af koden. + +**Det vi byggede.** `check_price` sammenligner prisen med `TARGET_PRICE`. `SmtpNotifier` forbinder med `smtplib` p氓 port 587, starter TLS, logger ind og sender beskeden. `SMTP_ADDRESS`, `EMAIL_ADDRESS` og `EMAIL_PASSWORD` l忙ses fra `.env` med `python-dotenv`; `.env.example` viser n酶glerne. + +Sk忙rmbillederne stammer fra en k酶rsel, hvor SMTP-forbindelsen er erstattet af en stub, s氓 der blev ikke sendt mail; det andet er tegnet ud fra den besked, koden bygger. + +![K酶rsel med en SMTP-stub](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-2-run.png) + +![Alarmbeskeden](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-2-email.png) + +**Det vi l忙rte** + +- SMTP-samtalen: connect, `starttls()`, `login()`, `sendmail()`; Gmail kr忙ver en app-adgangskode. +- Milj酶variabler og `.env`-filer holder hemmeligheder ude af repositoryet (`.env` st氓r i `.gitignore`). +- Reglen "under m氓let" er en lille ren funktion, der er let at teste (under, lig med, over). +- Tests med en falsk SMTP-klasse: testene sender aldrig rigtig mail. diff --git a/docs/wiki/Step-2-Email-Alert-ms.md b/docs/wiki/Step-2-Email-Alert-ms.md new file mode 100644 index 0000000..e86ec36 --- /dev/null +++ b/docs/wiki/Step-2-Email-Alert-ms.md @@ -0,0 +1,20 @@ +# Langkah 2: amaran e-mel + +馃寪 [English](Step-2-Email-Alert) 路 [Dansk](Step-2-Email-Alert-da) 路 **Bahasa Melayu** + +**Tugasan.** Apabila harga di bawah sasaran (100), hantar e-mel kepada diri sendiri dengan tajuk produk, harga dan pautan untuk membelinya. Jauhkan alamat e-mel dan kata laluan daripada kod. + +**Apa yang dibina.** `check_price` membandingkan harga dengan `TARGET_PRICE`. `SmtpNotifier` menyambung dengan `smtplib` pada port 587, memulakan TLS, log masuk dan menghantar mesej. `SMTP_ADDRESS`, `EMAIL_ADDRESS` dan `EMAIL_PASSWORD` dibaca daripada `.env` dengan `python-dotenv`; `.env.example` menunjukkan kuncinya. + +Tangkapan skrin datang daripada larian yang sambungan SMTP-nya diganti dengan stub, jadi tiada e-mel dihantar; yang kedua dilukis daripada mesej yang dibina oleh kod. + +![Larian dengan stub SMTP](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-2-run.png) + +![Mesej amaran](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-2-email.png) + +**Apa yang kita perolehi** + +- Perbualan SMTP: connect, `starttls()`, `login()`, `sendmail()`; Gmail memerlukan kata laluan aplikasi. +- Pemboleh ubah persekitaran dan fail `.env` menjauhkan rahsia daripada repositori (`.env` ada dalam `.gitignore`). +- Peraturan "di bawah sasaran" ialah fungsi tulen yang kecil dan mudah diuji (bawah, sama, atas). +- Ujian dengan kelas SMTP palsu: ujian tidak pernah menghantar e-mel sebenar. diff --git a/docs/wiki/Step-2-Email-Alert.md b/docs/wiki/Step-2-Email-Alert.md new file mode 100644 index 0000000..071ae7b --- /dev/null +++ b/docs/wiki/Step-2-Email-Alert.md @@ -0,0 +1,20 @@ +# Step 2: e-mail alert + +馃寪 **English** 路 [Dansk](Step-2-Email-Alert-da) 路 [Bahasa Melayu](Step-2-Email-Alert-ms) + +**Assignment.** When the price is below a target (100), send an e-mail to yourself with the product title, the price and a link to buy it. Keep the e-mail address and password out of the code. + +**What we built.** `check_price` compares the price with `TARGET_PRICE`. `SmtpNotifier` connects with `smtplib` on port 587, starts TLS, logs in and sends the message. `SMTP_ADDRESS`, `EMAIL_ADDRESS` and `EMAIL_PASSWORD` are read from `.env` with `python-dotenv`; `.env.example` shows the keys. + +The screenshots come from a run where the SMTP connection is replaced by a stub, so no mail was sent; the second one is rendered from the message the code builds. + +![Run with a stubbed SMTP connection](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-2-run.png) + +![The alert message](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-2-email.png) + +**What we gained** + +- The SMTP conversation: connect, `starttls()`, `login()`, `sendmail()`; Gmail needs an App Password. +- Environment variables and `.env` files keep secrets out of the repository (`.env` is in `.gitignore`). +- A "below the target" rule that is a tiny pure function and easy to test (below, equal, above). +- Tests with a fake SMTP class: no real mail is ever sent by the tests. diff --git a/docs/wiki/Step-3-Request-Headers-da.md b/docs/wiki/Step-3-Request-Headers-da.md new file mode 100644 index 0000000..bf8a4fa --- /dev/null +++ b/docs/wiki/Step-3-Request-Headers-da.md @@ -0,0 +1,20 @@ +# Trin 3: request headers + +馃寪 [English](Step-3-Request-Headers) 路 **Dansk** 路 [Bahasa Melayu](Step-3-Request-Headers-ms) + +**Opgave.** Send browser-lignende headers med foresp酶rgslen: mindst `User-Agent` og `Accept-Language`. + +**Det vi byggede.** `DEFAULT_HEADERS` i `constants.py` (uden `Host` og `X-Amzn-Trace-Id`) og `RequestsPageFetcher`, der sender dem som `headers=` til `requests.get`. + +Det en browser sender til httpbin.org/headers, og det botten sender (`Host` tilf酶jes af `requests`): + +![Headers sendt af en browser](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-3-browser-headers.png) + +![Headers sendt af botten](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-3-bot-headers.png) + +**Det vi l忙rte** + +- En foresp酶rgsel rummer mere end adressen: browser, system og sprog rejser med i headers. +- Med de rette headers kan en server svare p氓 dit sprog og i din valuta. +- Et script uden headers ligner en bot, og mange servere blokerer bots. +- 脡n skrivebeskyttet definition af headers og tests, der kontrollerer, hvad der sendes. diff --git a/docs/wiki/Step-3-Request-Headers-ms.md b/docs/wiki/Step-3-Request-Headers-ms.md new file mode 100644 index 0000000..2ffe6d3 --- /dev/null +++ b/docs/wiki/Step-3-Request-Headers-ms.md @@ -0,0 +1,20 @@ +# Langkah 3: header permintaan + +馃寪 [English](Step-3-Request-Headers) 路 [Dansk](Step-3-Request-Headers-da) 路 **Bahasa Melayu** + +**Tugasan.** Hantar header seperti pelayar bersama permintaan: sekurang-kurangnya `User-Agent` dan `Accept-Language`. + +**Apa yang dibina.** `DEFAULT_HEADERS` dalam `constants.py` (tanpa `Host` dan `X-Amzn-Trace-Id`) dan `RequestsPageFetcher`, yang menghantarnya sebagai `headers=` kepada `requests.get`. + +Apa yang pelayar hantar ke httpbin.org/headers, dan apa yang bot hantar (`Host` ditambah oleh `requests`): + +![Header yang dihantar oleh pelayar](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-3-browser-headers.png) + +![Header yang dihantar oleh bot](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-3-bot-headers.png) + +**Apa yang kita perolehi** + +- Permintaan membawa lebih daripada URL: pelayar, sistem dan bahasa dihantar dalam header. +- Dengan header yang betul, pelayan boleh menjawab dalam bahasa dan mata wang anda. +- Skrip tanpa header kelihatan seperti bot, dan banyak pelayan menyekat bot. +- Satu takrifan header yang baca sahaja, dan ujian yang menyemak apa yang dihantar. diff --git a/docs/wiki/Step-3-Request-Headers.md b/docs/wiki/Step-3-Request-Headers.md new file mode 100644 index 0000000..c2b4f4a --- /dev/null +++ b/docs/wiki/Step-3-Request-Headers.md @@ -0,0 +1,20 @@ +# Step 3: request headers + +馃寪 **English** 路 [Dansk](Step-3-Request-Headers-da) 路 [Bahasa Melayu](Step-3-Request-Headers-ms) + +**Assignment.** Send browser-like headers with the request: at least `User-Agent` and `Accept-Language`. + +**What we built.** `DEFAULT_HEADERS` in `constants.py` (without `Host` and `X-Amzn-Trace-Id`) and `RequestsPageFetcher`, which passes them as `headers=` to `requests.get`. + +What a browser sends to httpbin.org/headers, and what the bot sends (`Host` is added by `requests`): + +![Headers sent by a browser](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-3-browser-headers.png) + +![Headers sent by the bot](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-3-bot-headers.png) + +**What we gained** + +- A request carries more than the URL: the browser, the system and the language travel in headers. +- With the right headers a server can answer in your language and currency. +- A script without headers looks like a bot, and many servers block bots. +- One read-only definition of the headers, and tests that check what is sent. diff --git a/docs/wiki/Step-4-Live-Amazon-da.md b/docs/wiki/Step-4-Live-Amazon-da.md new file mode 100644 index 0000000..427bdd4 --- /dev/null +++ b/docs/wiki/Step-4-Live-Amazon-da.md @@ -0,0 +1,20 @@ +# Trin 4: den levende Amazon-side + +馃寪 [English](Step-4-Live-Amazon) 路 **Dansk** 路 [Bahasa Melayu](Step-4-Live-Amazon-ms) + +**Opgave.** Ret koden mod den rigtige Amazon-produktside, og udskriv pris og titel. + +**Hvad der skete.** Den 2026-10-28 svarede Amazon botten med HTTP 200 og en robotkontrol-side ("Click the button below to continue shopping") i stedet for produktet. Der var ingen pris at l忙se. + +![Siden Amazon returnerede](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-4-amazon-robot-check.png) + +**Det vi byggede.** `is_robot_check` genkender siden, og botten stopper med en tydelig besked. Den fors酶ger **ikke** at l酶se eller omg氓 kontrollen. Selektorer og mark酶rer st氓r i `constants.py`; `PRODUCT_URL` i `.env` v忙lger en anden side, fx 酶vesiden. + +![Botten p氓 den levende side](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-4-run.png) + +**Det vi l忙rte** + +- Levende websteder 忙ndrer sig og kan afvise scripts; 酶vesiden er den p氓lidelige basis. +- At fejle tydeligt er en del af arbejdet: en pr忙cis fejl sl氓r et traceback eller et forkert tal. +- Respekt for webstedet: ingen omveje uden om en botkontrol. +- Selektorer som data, s氓 en 忙ndring i markup er en enkelt linje. diff --git a/docs/wiki/Step-4-Live-Amazon-ms.md b/docs/wiki/Step-4-Live-Amazon-ms.md new file mode 100644 index 0000000..21f5e19 --- /dev/null +++ b/docs/wiki/Step-4-Live-Amazon-ms.md @@ -0,0 +1,20 @@ +# Langkah 4: halaman Amazon sebenar + +馃寪 [English](Step-4-Live-Amazon) 路 [Dansk](Step-4-Live-Amazon-da) 路 **Bahasa Melayu** + +**Tugasan.** Halakan kod ke halaman produk Amazon yang sebenar dan cetak harga serta tajuk. + +**Apa yang berlaku.** Pada 2026-10-28 Amazon menjawab bot dengan HTTP 200 dan halaman semakan robot ("Click the button below to continue shopping"), bukan produk. Tiada harga untuk dibaca. + +![Halaman yang dikembalikan Amazon](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-4-amazon-robot-check.png) + +**Apa yang dibina.** `is_robot_check` mengenali halaman itu dan bot berhenti dengan mesej yang jelas. Ia **tidak** cuba menyelesaikan atau melepasi semakan itu. Pemilih dan penanda ada dalam `constants.py`; `PRODUCT_URL` dalam `.env` memilih halaman lain, contohnya halaman latihan. + +![Output bot pada halaman sebenar](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-4-run.png) + +**Apa yang kita perolehi** + +- Laman sebenar berubah dan boleh menolak skrip; halaman latihan ialah asas yang boleh dipercayai. +- Gagal dengan jelas ialah sebahagian daripada kerja: ralat khusus lebih baik daripada traceback atau nombor yang salah. +- Menghormati laman: tiada jalan pintas untuk semakan bot. +- Pemilih disimpan sebagai data, jadi perubahan markup hanyalah satu baris. diff --git a/docs/wiki/Step-4-Live-Amazon.md b/docs/wiki/Step-4-Live-Amazon.md new file mode 100644 index 0000000..2dacdaf --- /dev/null +++ b/docs/wiki/Step-4-Live-Amazon.md @@ -0,0 +1,20 @@ +# Step 4: the live Amazon page + +馃寪 **English** 路 [Dansk](Step-4-Live-Amazon-da) 路 [Bahasa Melayu](Step-4-Live-Amazon-ms) + +**Assignment.** Point the code at the real Amazon product page and print the price and the title. + +**What happened.** On 2026-10-28 Amazon answered the bot with HTTP 200 and a robot-check page ("Click the button below to continue shopping"), not the product. There was no price to read. + +![The page Amazon returned](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-4-amazon-robot-check.png) + +**What we built.** `is_robot_check` recognises that page and the bot stops with a clear message. It does **not** try to solve or get past the check. Selectors and markers are in `constants.py`; `PRODUCT_URL` in `.env` chooses another page, for example the practice page. + +![Output of the bot on the live page](https://git.tirsystem.com/Tirsvad-Udemy-100-days-of-code/047-amazon-price-tracker/raw/branch/main/docs/images/step-4-run.png) + +**What we gained** + +- Live sites change and may refuse scripts; the practice page is the reliable baseline. +- Failing clearly is part of the job: a specific error beats a traceback or a wrong number. +- Respect for the site: no workarounds for a bot check. +- Selectors kept as data, so a markup change is a one-line edit. diff --git a/docs/wiki/_Sidebar.md b/docs/wiki/_Sidebar.md new file mode 100644 index 0000000..a95688b --- /dev/null +++ b/docs/wiki/_Sidebar.md @@ -0,0 +1,13 @@ +**Amazon Price Tracker** + +- [Home](Home) +- [Step 1: scrape the price](Step-1-Scrape-the-Price) +- [Step 2: e-mail alert](Step-2-Email-Alert) +- [Step 3: request headers](Step-3-Request-Headers) +- [Step 4: live Amazon page](Step-4-Live-Amazon) + +**Languages** + +- English: [Home](Home) +- Dansk: [Hjem](Home-da) +- Bahasa Melayu: [Utama](Home-ms)