Can webbrowser module get source code?

Discussion in 'Python' started by Muddy Coder, Jan 24, 2009.

  1. Muddy Coder

    Muddy Coder Guest

    Hi All,

    I played the demo of webbrowser module, with the code below:

    import webbrowser
    url = 'https://login.yahoo.com'
    webbrowser.open_new_tab(url)

    when I ran the code, it popped out a webpage nicely. I want to go
    further: to get the source code of the webpage being displayed. Is it
    possible to do it? I tried webbrow.get() but didn't work. Somebody can
    help? Thanks!


    Muddy Coder
    Muddy Coder, Jan 24, 2009
    #1
    1. Advertising

  2. Muddy Coder <cosmo_general <at> yahoo.com> writes:
    > I want to go
    > further: to get the source code of the webpage being displayed. Is it
    > possible to do it? I tried webbrow.get() but didn't work. Somebody can
    > help? Thanks!


    To do this, you actually need to fetch the page yourself:

    import urllib2
    page_source = urllib2.urlopen("http://someaddress.com").read()

    >
    Benjamin Peterson, Jan 25, 2009
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. David Stockwell
    Replies:
    0
    Views:
    439
    David Stockwell
    Jun 10, 2004
  2. SPE - Stani's Python Editor

    Firefox bug in webbrowser module on Ubuntu?!

    SPE - Stani's Python Editor, Jan 20, 2006, in forum: Python
    Replies:
    5
    Views:
    397
    Jarek Zgoda
    Jan 22, 2006
  3. Blair P. Houghton
    Replies:
    19
    Views:
    495
    Blair P. Houghton
    Feb 2, 2006
  4. robin
    Replies:
    0
    Views:
    374
    robin
    May 18, 2006
  5. robin

    webbrowser module bug on os x?

    robin, May 25, 2006, in forum: Python
    Replies:
    0
    Views:
    224
    robin
    May 25, 2006
Loading...

Share This Page