• Resolved four321zero

    (@four321zero)


    My site is https://trekkipedia.in

    Am not at all familiar with PHP and have no knowledge of scripting either.

    My question: Is it possible to create a widget or something on those lines to fetch data from an external site and display it in the sidebar of my website in a customized format.

    The source site:
    https://leh.nic.in/

    If you look on the left hand side of this page; there is a section for “Road Status”. I would like my site to fetch content from this site and update mine accordingly.

    Similarly there are other sources with information on road status and weather conditions. Would like to incorporate that data into mine without having to manually update it every few days.

    P.S.
    I have tried
    ELI’s SHORTCURL Shortcodes to Fetch and Parse External Content
    &
    Fetch URL – Fetch and Parse External Content
    But could not understand how to use them. Dont even know if they serve the purpose.

Viewing 6 replies - 1 through 6 (of 6 total)
  • I don’t know think there’s a good way to do this unless leh.nic.in offers an API to access that data.

    Thread Starter four321zero

    (@four321zero)

    Appreciate your reply. Am not very familiar with these terms, so am not sure if i understand this well. But is there any way for me to verify whether these external sites allow this thing? Eventually I would be looking at not just leh.nic but also a couple of other sites for other data.

    Also, Do I need to know any coding to put this in effect?

    But is there any way for me to verify whether these external sites allow this thing?

    If they do, it’s usually documented somewhere on their website in a developer section. You can always reach out to them and ask.

    Eventually I would be looking at not just leh.nic but also a couple of other sites for other data.

    Most sites that collect any kind of data, that’s designed to be shared, offer an API to developers so that the content can be obtained and displayed on third-party sites.

    Also, Do I need to know any coding to put this in effect?

    Yes, you’ll need to (most likely) learn about how to use a REST API and then use a language of your choice (like PHP) to retrieve the data via the API.

    The reason Matt said that an API would be a good way, is because with an API, you can ask a website for very specific information and it will give it to you in a very reliable way. Then you can use this information and present it anyway you like on your website.

    Without an API, you would most likely need to scrape the website, which means writing your own parser to obtain that information. Depending on your implementation, however, this is not reliable, because if the website changes its markup, there is a chance your parser will break.

    Aside from the technical challenges, you would also need to carefully review the site’s terms of use and check whether scraping their site is allowed.

    Thread Starter four321zero

    (@four321zero)

    Matt and Ryan, you have been very helpful.

    At this time learning PHP would be a long shot for me. I’ll probably feed the data manually in that case.
    What do you reckon using? Should I simply use HTML/CSS and create the sidebar boxes and tables i need? Or is there a faster and neater way of doing it with some widgets or tools?

    If your theme already has sidebar support, you can just use a text widget and enter your HTML there. That’s the quickest way.

    A more elegant solution would be to create a custom widget, add fields for your data, and then style it when it’s displayed. This allows you to swap the info a little easier and without having to read through HTML. Take a look at the Widget API for more info on that (but that would also require you to learn a bit of PHP).

    Thread Starter four321zero

    (@four321zero)

    Thanks again Ryan. Wish you all a Happy New Year!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How do i fetch data from an external site?’ is closed to new replies.