# Tracking train availability

**URL:** <https://forums.distill.io/t/tracking-train-availability/1661>\
**Category:** Help and Support\
**Tags:** macros\
**Created:** [February 21, 2023, 8:06am UTC](https://forums.distill.io/t/tracking-train-availability/1661 "2023-02-21T08:06:33Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [February 21, 2023, 8:06am UTC](https://forums.distill.io/t/tracking-train-availability/1661/1 "2023-02-21T08:06:33Z")

</div>

Hey! I’m a new user. I would like to know is it possible to track specific type of train from train booking website? variables: train name; departure time, seat availability

---

<div class="post-metadata">

**Author:** ![ajitk](https://forums.distill.io/letter_avatar_proxy/v4/letter/a/ec9cab/32.png) [@ajitk](https://forums.distill.io/u/ajitk)\
**Post date:** [February 21, 2023, 1:38pm UTC](https://forums.distill.io/t/tracking-train-availability/1661/2 "2023-02-21T13:38:45Z")

</div>

It should be possible @ikhabibullaev. Did you face any challenge monitoring them for availability?

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [February 22, 2023, 10:36am UTC](https://forums.distill.io/t/tracking-train-availability/1661/3 "2023-02-22T10:36:10Z")

</div>

Yes, I could not use it.

---

<div class="post-metadata">

**Author:** ![ajitk](https://forums.distill.io/letter_avatar_proxy/v4/letter/a/ec9cab/32.png) [@ajitk](https://forums.distill.io/u/ajitk)\
**Post date:** [February 22, 2023, 1:59pm UTC](https://forums.distill.io/t/tracking-train-availability/1661/4 "2023-02-22T13:59:18Z")

</div>

What problem did you encounter? If you can share more details about the use case and challenges faced, that will be great. Thanks!

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 5, 2023, 8:04am UTC](https://forums.distill.io/t/tracking-train-availability/1661/5 "2023-03-05T08:04:35Z")

</div>

Hey! Thanks for reaching out. We have 4 variables to track: date, train type, departure time & availability.

I want to create a notification if all these 4 variables match.

- How can I track the date?
- Train type is quite easy if the field equal to “Afrosiyob” word
- Departure time is also very easy, just departure time
- Availability is quite complex, when there are no seats there’s always text that says no train available when there’s seats available they will list the number of seats available
- Class of the train we can track by price

I could not do all of these myself, I need some assistance to set up

Please refer to the attachment

 ![Screenshot 2023-03-05 at 12.56.25](https://forums.distill.io/uploads/default/original/1X/9c930ac24b4d101a1f2e8c8587411ea3b63322c3.jpeg)

---

<div class="post-metadata">

**Author:** ![cobramonk](https://forums.distill.io/user_avatar/forums.distill.io/cobramonk/32/353_2.png) [@cobramonk](https://forums.distill.io/u/cobramonk)\
**Post date:** [March 6, 2023, 11:47am UTC](https://forums.distill.io/t/tracking-train-availability/1661/6 "2023-03-06T11:47:05Z")

</div>

Hi @ikhabibullaev ,

You want to filter the train list based on date, train type, starting and ending stations. And extract the filtered train list along with available number of seats. Would that be correct ? If incorrect, please explain your requirement in detail.

Also, can you please share the URL from which you want to monitor the data ?

Thanks.

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 6, 2023, 11:59am UTC](https://forums.distill.io/t/tracking-train-availability/1661/7 "2023-03-06T11:59:47Z")

</div>

Yes, it’s correct

Here’s the link: [O'zbekiston Temir Yo'llari](https://chipta.railway.uz/en/home)

---

<div class="post-metadata">

**Author:** ![cobramonk](https://forums.distill.io/user_avatar/forums.distill.io/cobramonk/32/353_2.png) [@cobramonk](https://forums.distill.io/u/cobramonk)\
**Post date:** [March 6, 2023, 4:48pm UTC](https://forums.distill.io/t/tracking-train-availability/1661/8 "2023-03-06T16:48:54Z")

</div>

Please follow the steps below to create the monitor:

1. Save the following text into a “.json” file.

```auto
{"macros":[{"meta":{"url":"https://chipta.railway.uz/en/home"},"name":"chipta railway","spec":{},"steps":[["wait_doc",{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"[placeholder='From']"}],{"x":164.5,"y":11},{"frame":0}],["type",["selector",{"meta":{},"type":"css","value":"[placeholder='From']"}],"sam",{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"li.search-trains __dropdown__ item:first-child"}],{"x":63.5,"y":20},{"frame":0}],["type",["selector",{"meta":{},"type":"css","value":".search-trains__input--to"}],"tashk",{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"li.search-trains__dropdown__item:nth-child(3)"}],{"x":71.890625,"y":14},{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"[alt='calendar\\ icon']"}],{"x":12.171875,"y":9},{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":".ngb-dp-day[aria-label$='March 15, 2023']"}],{"x":16.28125,"y":13},{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"[type='submit']"}],{"x":82.0625,"y":24},{"frame":0}],["wait_for_element",["selector",{"meta":{},"type":"css","value":".direction__heading"}],{"frame":0}]],"version":1}]}

```

You can copy the above code, open your favourite text editor, paste the code and save the file in the following format `filename.json`.

1. Go to distill’s watchlist page and click on the hamburger icon. In the menu, click on `Macros`.

 ![Screenshot 2023-03-06 at 9.37.04 PM](https://forums.distill.io/uploads/default/original/1X/1e3d3ae174bf8a2e0278739bc50e00a9ae1932e9.png)

This will open the macros page.

1. Click on the `Import Macro` button and choose the saved json file to upload.

 ![Screenshot 2023-02-26 at 1.41.14 PM](https://forums.distill.io/uploads/default/original/1X/db62dc9103dfa09419f87e0b6517a95e55808a82.png)

1. Once you upload the json file, you should see a new macro added with the name `chipta railway`.  

2. Now go back to distill’s watchlist page and click on the hamburger icon. In the menu, click on `Import > JSON`.  

3. In the import page, paste the following config and click import.

```auto
{"client":{"web":1},"data":[{"name":"O'zbekiston Temir Yo'llari","uri":"https://chipta.railway.uz/en/home","content_type":2,"config":"{\"selections\":[{\"frames\":[{\"index\":0,\"excludes\":[],\"includes\":[{\"expr\":\"//li[contains(@class,'info')][contains(string(),'Afrosiyob')]\",\"type\":\"xpath\"}]}],\"dynamic\":true,\"delay\":0}],\"regexp\":null,\"ignoreEmptyText\":true,\"includeStyle\":false,\"viewport\":{},\"dataAttr\":\"text\"}","schedule":"{\"type\":\"INTERVAL\",\"params\":{\"interval\":259}}","state":40,"tags":null,"ts":"2023-03-06T15:49:31.191Z","datasource_id":null,"rule":"{\"type\":2,\"op\":1,\"rules\":[{\"type\":1,\"contentType\":2,\"rule\":{\"type\":2,\"params\":{\"input\":\"Choose train\"}}}],\"numberFormat\":\"1,.\"}"}]}

```

 ![Screenshot 2023-03-06 at 9.41.32 PM](https://forums.distill.io/uploads/default/original/1X/6ab93fc0064dd83af32b80e0c1d8851f0c0e58c2.png)

1. Click on the back button to go back to Watchlist. You should be able to see your new monitor with name `O'zbekiston Temir Yo'llari`. Click on the `downward triangle to the left of the name`. Choose `Edit options`.

 ![Screenshot 2023-03-06 at 9.42.12 PM](https://forums.distill.io/uploads/default/original/1X/0f78adc45edeb6f7023f20825577037d44f5a6ee.png)

1. Choose the `Empty-Macro` dropdown and click on `chipta railway` option. Now click save.

 ![Screenshot 2023-03-06 at 9.42.35 PM](https://forums.distill.io/uploads/default/original/1X/de6b8f4eaf9a65a518b850b61e8d242d1ed1edc6.png)

Following the above steps should successfully setup the required monitor.

Note:

1. The condition to notify only when trains are available is already added. Add the action that has to happen ( Eg: send email) when condition become true.

2. The macro is set to check for Date ‘March 15, 2023’. You can change that in the Macro config shared in the first step, to check for a different date.

3. The first check might error out, since it will start checking even before you set the macro in the `Edit options`. Wait for the second check, after choosing the macro and saving in `Edit options`.

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 6, 2023, 9:17pm UTC](https://forums.distill.io/t/tracking-train-availability/1661/9 "2023-03-06T21:17:45Z")

</div>

Hey! I followed up but there’s an error.  
If I want to track other dates, should I always upload new .json file? is there any convenient way of doing it? and how can modify train departure times? if I want to receive notification for only specific train departure times

 ![image](https://forums.distill.io/uploads/default/original/1X/fd54246c8ebcaad4d48d69883273c3f317236c15.jpeg)

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 6, 2023, 9:21pm UTC](https://forums.distill.io/t/tracking-train-availability/1661/10 "2023-03-06T21:21:14Z")

</div>

Also, I need to choose the departure city and arrival city. how can I do that?

---

<div class="post-metadata">

**Author:** ![cobramonk](https://forums.distill.io/user_avatar/forums.distill.io/cobramonk/32/353_2.png) [@cobramonk](https://forums.distill.io/u/cobramonk)\
**Post date:** [March 7, 2023, 4:08am UTC](https://forums.distill.io/t/tracking-train-availability/1661/14 "2023-03-07T04:08:27Z")

</div>

From the snapshot we can see that we are still in the landing page. This means that the steps in the macro has not been played. Did you add the macro to the Edit options of the monitor, As shown below ?

 ![Screenshot 2023-03-06 at 9.42.35 PM](https://forums.distill.io/uploads/default/original/1X/de6b8f4eaf9a65a518b850b61e8d242d1ed1edc6.png)

---

<div class="post-metadata">

**Author:** ![cobramonk](https://forums.distill.io/user_avatar/forums.distill.io/cobramonk/32/353_2.png) [@cobramonk](https://forums.distill.io/u/cobramonk)\
**Post date:** [March 7, 2023, 4:12am UTC](https://forums.distill.io/t/tracking-train-availability/1661/15 "2023-03-07T04:12:43Z")

</div>

It has to be edited in the macro. There is no way providing them as a parameter as of now. Editing the config wouldn’t work for changing departure city and arrival city. You have to record a new macro.

Here is a link on how to record macros.

> **[Macro: Record and Replay Automated Actions | Distill](https://distill.io/docs/web-monitor/macro-to-record-replay-actions/)**
>
> Use visual recorder to easily record macros. Use the macro to access content that requires you to take actions such as filling a form or clicking elements to show more details.

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 7, 2023, 7:00am UTC](https://forums.distill.io/t/tracking-train-availability/1661/16 "2023-03-07T07:00:20Z")

</div>

How can I do that? I purchased subscription to use macro features; but stuck on configuration

---

<div class="post-metadata">

**Author:** ![cobramonk](https://forums.distill.io/user_avatar/forums.distill.io/cobramonk/32/353_2.png) [@cobramonk](https://forums.distill.io/u/cobramonk)\
**Post date:** [March 7, 2023, 8:27am UTC](https://forums.distill.io/t/tracking-train-availability/1661/17 "2023-03-07T08:27:37Z")

</div>

Were you able to record macro by referring to the link shared in the previous message? If you are facing difficulty in creating the macro, can you explain in which step you are stuck? So that I can help you set it up.

Thanks.

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 7, 2023, 9:14am UTC](https://forums.distill.io/t/tracking-train-availability/1661/18 "2023-03-07T09:14:18Z")

</div>

I just can’t add departure city and arrival city in Macro; basically, we have 5 variables (earlier I forgot to mention departure city in the variables); date, train type, departure city & arrival city, departure time, and no of seats.

How can I add departure and arrival city in the variable using macros?

---

<div class="post-metadata">

**Author:** ![cobramonk](https://forums.distill.io/user_avatar/forums.distill.io/cobramonk/32/353_2.png) [@cobramonk](https://forums.distill.io/u/cobramonk)\
**Post date:** [March 7, 2023, 10:08am UTC](https://forums.distill.io/t/tracking-train-availability/1661/19 "2023-03-07T10:08:25Z")

</div>

Are you trying to create a new Macro, or are you trying to edit the macro config I previously shared ?

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 7, 2023, 10:27am UTC](https://forums.distill.io/t/tracking-train-availability/1661/20 "2023-03-07T10:27:22Z")

</div>

I tried to edit the macro you sent

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 7, 2023, 10:28am UTC](https://forums.distill.io/t/tracking-train-availability/1661/21 "2023-03-07T10:28:38Z")

</div>

based on the macro you sent (departure is from Samarkand; to Tashkent); now I changed to (from Tashkent to Samarkand) but there’s error

---

<div class="post-metadata">

**Author:** ![cobramonk](https://forums.distill.io/user_avatar/forums.distill.io/cobramonk/32/353_2.png) [@cobramonk](https://forums.distill.io/u/cobramonk)\
**Post date:** [March 7, 2023, 11:12am UTC](https://forums.distill.io/t/tracking-train-availability/1661/22 "2023-03-07T11:12:05Z")

</div>

```auto
{"macros":[{"meta":{"url":"https://chipta.railway.uz/en/home"},"name":"chipta railway","spec":{},"steps":[["wait_doc",{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"[placeholder='From']"}],{"x":164.5,"y":11},{"frame":0}],["type",["selector",{"meta":{},"type":"css","value":"[placeholder='From']"}],"tashk",{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"li.search-trains __dropdown__ item:nth-child(3)"}],{"x":63.5,"y":20},{"frame":0}],["type",["selector",{"meta":{},"type":"css","value":".search-trains__input--to"}],"sam",{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"li.search-trains__dropdown__item:first-child"}],{"x":71.890625,"y":14},{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"[alt='calendar\\ icon']"}],{"x":12.171875,"y":9},{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":".ngb-dp-day[aria-label$='March 15, 2023']"}],{"x":16.28125,"y":13},{"frame":0}],["click",["selector",{"meta":{},"type":"css","value":"[type='submit']"}],{"x":82.0625,"y":24},{"frame":0}],["wait_for_element",["selector",{"meta":{},"type":"css","value":".direction__heading"}],{"frame":0}]],"version":1}]}

```

This is a working macro for departure from TASHKENT and arrival at SAMARKAND. Directly editing the previous macro, for swapping departure and arrival, won’t work.

It is easier to record a macro than to edit the config.

All you have to do is, in the macros page:

1. Enter the name of macro and URL.
2. Click on `Add New Macro`. A recorder will open, with a builtin browser.
3. You just have to enter the departure station, arrival station, date and click on search. The steps will be automatically recorded.
4. Click on Save, The macro will be saved.

Please refer to this link for detailed explanation and examples:

> **[Macro: Record and Replay Automated Actions | Distill](https://distill.io/docs/web-monitor/macro-to-record-replay-actions/)**
>
> Use visual recorder to easily record macros. Use the macro to access content that requires you to take actions such as filling a form or clicking elements to show more details.

–x–

I will add a screen-recording to show how to record a macro, shortly.

---

<div class="post-metadata">

**Author:** ![ikhabibullaev](https://forums.distill.io/user_avatar/forums.distill.io/ikhabibullaev/32/326_2.png) [@ikhabibullaev](https://forums.distill.io/u/ikhabibullaev)\
**Post date:** [March 7, 2023, 1:40pm UTC](https://forums.distill.io/t/tracking-train-availability/1661/23 "2023-03-07T13:40:56Z")

</div>

I created a New macro: Tash-Sam; however, it’s not working. It’s not showing any notifications with train availability. Should I select train class when I record a new macro? or just departure city, arrival city, and dates would be enough? I only want to get a notification when the train name equals “Afrosiyob”; departure times: 07:28, 08:00 and 08:23. How can add this logic there?

[Next page](https://forums.distill.io/t/tracking-train-availability/1661.md?page=2)
