Hack Forums
[Python] How to save data from webpage visit? - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] How to save data from webpage visit? (/showthread.php?tid=6018886)



How to save data from webpage visit? - Red-Leonard - Oct 23, 2019

I have a tool on my webpage that displays the users ip address when they visit (this displays as json on the page)

but, how to save that data so that I can view it later?

the website is hosted on flask/python

so I guess i need a basic script/task that will save the data on file somewhere - how? thanks


RE: How to save data from webpage visit? - MavenGradle - Oct 23, 2019

You're talking about access logging and analytical statistics, I suppose. Google Analytics is good at analytical statistics and you might want to look into your server logs and how you can use those to track activity:

https://flask.palletsprojects.com/en/1.1.x/logging/

You can later analyse those access logs and write a tool to display them visually on your administrative panel.


RE: How to save data from webpage visit? - Red-Leonard - Oct 23, 2019

I can get the ip address already, with a python snippet inserted into the page code

when I access my own page, I can see my ip address, but I want to see other peoples' visits - ie. save the ip address that shows on the screen

can this be done with a simple 'always on task' or some kind of scraping?

Google analytics doesn't show the ip addresses


RE: How to save data from webpage visit? - MavenGradle - Oct 23, 2019

(Oct 23, 2019 09:19 PM)Red-Leonard Wrote:  I can get the ip address already, with a pyhton snippet inserted into the page code

when I access my own page, I can see my ip address, but I want to see other peoples' visits - ie. save the ip address that shows on the screen

can this be done with a simple 'always on task' or some kind of scraping?

Google analytics doesn't show the ip addresses

I really don't understand what you mean by that. I already told you about access logs and how you can essentially write their IP addresses in those logs? Am I missing something here? You do know what an access log is, right?

Code
app.logger.info('%s logged in successfully', user.ip) # This is an example
https://flask.palletsprojects.com/en/1.1.x/logging/


RE: How to save data from webpage visit? - Red-Leonard - Oct 23, 2019

I've looked at access logs, and no ip details in there

my bad, you are right


I've found the access logs!

I was mistakenly looking in the 'server logs'

thanks all the same!