Edit webpage in browser

Edit webpage in browser

Postby grim of doom » Mon Jul 21, 2014 2:42 am

I'm not sure if it exactly fits in this category,but I am interested in knowing if it is possible with python(2.7) to edit a web page that is already loaded/before-after it shows in browser. I know you can make stuff like search engines and such by looking inside HTML for the link tags('<a href=>' and '</a>'). I have tried looking around online and have come up with nothing anywhere close to what I am looking for.
grim of doom
 
Posts: 20
Joined: Thu Jul 10, 2014 3:16 am

Re: Edit webpage in browser

Postby metulburr » Mon Jul 21, 2014 5:16 am

Im not sure what exactly you are looking for?

Automate a web browser? Selenium
Obtain the web sites HTML and display it modified? urllib and webbrowser modules
Or do you mean like javascript?
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1560
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Edit webpage in browser

Postby grim of doom » Tue Jul 22, 2014 7:39 am

Modifying a web page's URL and display it in web browser-from URL. I've read through the pages of urllib2 and webbrowser modules for python 2.7 you showed. From the jitz of reading it(I do not fully understand them in honesty) but I'm guessing I would use the urllib2 module can be used to grab the data from a URL, then I can use it with webbrowser to make it display in browser.

I can grab using the urllib2.openurl('URL') but once I make a change to it,how I can push it into the browser.
grim of doom
 
Posts: 20
Joined: Thu Jul 10, 2014 3:16 am

Re: Edit webpage in browser

Postby metulburr » Tue Jul 22, 2014 1:55 pm

I can grab using the urllib2.openurl('URL') but once I make a change to it,how I can push it into the browser.

Before opening it in the browser, you would do your changes, write it to a file, and open the file with
Code: Select all
webbrowser.open('filename.html')



Code: Select all
import webbrowser
from urllib2 import urlopen

site = 'http://www.metulburr.com'

req = urlopen(site)
html = req.read()

#modify html

with open('test.html', 'w') as f:
    f.write(html)
   
webbrowser.open('test.html')
New Users, Read This
OS Ubuntu 14.04, Arch Linux, Gentoo, Windows 7/8
https://github.com/metulburr
steam
User avatar
metulburr
 
Posts: 1560
Joined: Thu Feb 07, 2013 4:47 pm
Location: Elmira, NY

Re: Edit webpage in browser

Postby grim of doom » Tue Jul 22, 2014 7:01 pm

I think I get it, so I grab the HTML from online, edit it/ save it and then replace it?
I was thinking of making an app for making x-web pages themed as I go into them, like changing Facebook or Goigle to have a different background color.

Edit: I finally got onto my laptop and tried using it, not exactly what I was trying to do. What I want to do is use python the edit the HTML while it is in the browser, the same as if I were using the developer tools (right click-inspect element in google chrome) and change it. Was hoping I could do this and automate it so it does it for me every time I enter the website with 'URL.blah'.
grim of doom
 
Posts: 20
Joined: Thu Jul 10, 2014 3:16 am


Return to Web Development

Who is online

Users browsing this forum: No registered users and 1 guest