Python Forum
Write from URL with changing information to textfile
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Write from URL with changing information to textfile
#1
Hi,

I am very new to python coding and have a question that is hopefully a simple fix.
I am an intern for a company who is developing some drones for agricultural use and need to export some data from the drone's companion computer. It is not important that you are familiar with MAVLink, but I'll explain it a bit for clarification.

When the drone's flight controller is hooked up to my laptop via USB, I am able to connect MAVLink and see the real time location values, such as latitude, longitude and altitude. By inserting a specific link into the web browser, I am able to see those values display. However, this information changes. For example, if if I run that link when the controller is flat, and then run it again with it turned 90 degrees, I'll get different attributes in the web browser.

To sum it up: I have a web browser link that holds a short amount of constantly changing information. I am already able to export the text from the browser using the short code below...but that textfile it generates only holds the information that the link held at the exact time I can the code. So, I need a way to make this textfile update every 10 seconds or so with the changing information, and store the old values.
E.g.
VALUE(S) #1 @10 seconds
VALUE(S) #2 @20 seconds
VALUE(S) #3 @30 seconds
Multiple textfiles is fine too...I just need a way to export the changing information from the link in some type of thread.



Thanks in advance!

import urllib

urllib.urlretrieve("link here", "test1.txt")
P.S. I cant provide the actual link since it's my first post on this forum...for anti-spam measures.
Reply
#2
while True:
    # get the new data
    # if any
        # rename the old file name
        with open('new_file.txt', 'w') as new:
            new.write(data)
    
    time.sleep(10)
For example
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  textfile to customtkinter combobox janeik 6 1,790 Aug-31-2023, 02:50 AM
Last Post: deanhystad
  Importing python data to Textfile or CSV yanDvator 0 1,763 Aug-02-2020, 06:58 AM
Last Post: yanDvator
  Replace Line in Textfile Deadline 1 10,386 Nov-04-2019, 07:14 PM
Last Post: Larz60+
  Compare input() to textfile Trianne 4 3,523 Sep-29-2018, 02:32 PM
Last Post: gruntfutuk
  Write a for loop on list of lists without changing the shape of the main list Antonio 3 3,766 Jun-19-2018, 02:16 AM
Last Post: ichabod801
  Loop thru textfile, change 3 variables for every line herbertioz 11 9,155 Nov-10-2016, 04:56 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020