How to keep track of webpages opened in web-browser using Python? -


i want write python script can keep track of webpages have been opened in webbrowser(mozilla firefox 23). don't know start. standard webbrowser module of python allows webpages opened standard documentation doesn't have interacting webpage.

so need write plugin browser can send data python script missing functionality standard library?

i have looked @ related questions this simulating web-browser in python using mechanize and/or selenium. don't want that. want data webbrowser in using standard python libraries.

edit

just add more clarity question, want keep track of current webpages open in firefox.

this answer may bit fuzzy -- because question not extremely specific.

if understand well, want examine history of visited pages. problem is not directly related html, nor http protocol, nor web services. history (that can observe in firefox when pressing ctrl-h) tool implemented in firefox , such, implementation dependent. there can no standard library capable extract information.

as http protocol , content of pages in html, there nothing interaction content of pages. protocol uses url argument, , web server sends text body meta information. caller (the browser) can returned data. browser uses tagged text , interprets readable document parts rendered nicely possible. interaction (clicking on href) implemented browser. causes other commands of http protocol.

to answer question, need find how mozilla firefox 23 stores history. can find somewhere in internal sqlite databases.

update 2015-08-24: see erasmortg's comment changes of placing information in firefox. (the text below older one.)

update: list of open tabs bound user. want windows, should first path c:\users\myname.mydomain\appdata\roaming\mozilla\firefox\profiles\yoodw5zk.default-1375107931124\sessionstore.js. profile name should extracted c:\users\myname.mydomain\appdata\roaming\mozilla\firefox\profiles.ini. have copied sessionstore.js trying data. says javascript, did use standard json module parse it. dictionary. 1 of items key 'windows' contains dictionary, , 'tabs' in turn contains information tabs.

copy sessionstore.js working directory , execute following script there:

#!python3  import json  open('sessionstore.js', encoding='utf-8') f:     content = json.load(f)  # loaded content dictionary. list keys first (console). k in content:     print(k)  # list content bound keys. console may not capable # display characters, write file. open('out.txt', 'w', encoding='utf-8') f:      # write overview of content.     k, v in content.items():         # write key , type of value.         f.write('\n\n{}:  {}\n'.format(k, type(v)))          # value of list type, or 1 item.         if isinstance(v, list):             e in v:                 f.write('\t{}\n'.format(e))         else:             f.write('\t{}\n'.format(v))      # write content of tabs in each windows.     f.write('\n\n=======================================================\n\n')     windows = content['windows']     n, w in enumerate(windows, 1):  # enumerate used numbering windows         f.write('\n\twindow {}:\n'.format(n))         tabs = w['tabs']         tab in tabs:             # tab dictionary. display 'title' , 'url'              # 'entries' subdictionary.             e = tab['entries'][0]             f.write('\t\t{}\n\t\t{}\n\n'.format(e['url'], e['title'])) 

the result both displayed on console (few lines), , written out.txt file in working directory. out.txt (at end of file) contains in case:

window 1:     http://www.cyrilmottier.com/     cyril mottier      http://developer.android.com/guide/components/fragments.html#communicatingwithactivity     fragments | android developers      http://developer.android.com/guide/components/index.html     app components | android developers      http://www.youtube.com/watch?v=onad1mb8r-a     ▶ introducing robospice: robust asynchronous networking library android - youtube      http://www.youtube.com/watch?v=5a91dblx8qc     rocking gradle hans dockter - youtube      http://stackoverflow.com/questions/18439564/how-to-keep-track-of-webpages-opened-in-web-browser-using-python     how keep track of webpages opened in web-browser using python? - stack overflow      https://www.google.cz/search?q=mozilla+firefox+list+of+open+tabs&ie=utf-8&oe=utf-8&rls=org.mozilla:cs:official&client=firefox-a&gws_rd=cr     mozilla firefox list of open tabs - hledat googlem      https://addons.mozilla.org/en-us/developers/docs/sdk/latest/dev-guide/tutorials/list-open-tabs.html     list open tabs - add-on sdk documentation      https://support.mozilla.org/cs/questions/926077     list tabs button not showing | fórum podpory firefoxu | podpora mozilly      https://support.mozilla.org/cs/kb/scroll-through-your-tabs-quickly     scroll through tabs | nápověda k firefox 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -