python - Getting contents of a URL and comparing locally -


I'm looking to get a URL (it's just a line, no HTML, plain text) Every 3,000 seconds I want to compare it against "previous.txt" and call the function if it is different, then write it on previous.txt.

If it is the same then do nothing. Can someone ask me to start at some place? I am not a dragon long ago.

Thank you.

"post-text" itemprop = "text">

Here are some hints. In

Try to see your question tags will help you already know urlib urllib2.urlopen () data from the URL.

Comparison of past and present content is as simple as reading in the contents of previous.txt and compare the string whatever you have received from the URL. If two strings are different, write a new one in the file. For your file Io and see read / write .

If your Python process is running for a long time, then every 3000 seconds can be used by using <600> time.sleep to complete the task () or signal.alarm () (or several other ways).

Comments