Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58195

Re: how to extract page-URL using BeautifulSoup

Date 2013-10-31 17:36 +0000
From MRAB <python@mrabarnett.plus.com>
Subject Re: how to extract page-URL using BeautifulSoup
References <7fb9c035-c663-4874-9597-ac47d1c30da7@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.1886.1383240984.18130.python-list@python.org> (permalink)

Show all headers | View raw


On 31/10/2013 15:59, bhaktanishant@gmail.com wrote:
> I want to extract the page-url. for example:
> if i have this code
>
> import urllib2
> from bs4 import BeautifulSoup
> link = "http://www.google.com"
> page = urllib2.urlopen(link).read()
> soup = BeautifulSoup(page)
>
> then i can extract title of page by:
>
> title = soup.title
>
> but i want to know that how to extract page-URL from "soup" that will be "http://www.google.com"
>
Have a look at what you're passing to BeautifulSoup (save it to a file
and look at it in an editor). It's HTML. Does it contain anything that
says where it came from? No. So BeautifulSoup can't know either.

All BeautifulSoup does is parse the HTML that it's given.

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

how to extract page-URL using BeautifulSoup bhaktanishant@gmail.com - 2013-10-31 08:59 -0700
  Re: how to extract page-URL using BeautifulSoup MRAB <python@mrabarnett.plus.com> - 2013-10-31 17:36 +0000
  Re: how to extract page-URL using BeautifulSoup Alister <alister.ware@ntlworld.com> - 2013-11-01 11:33 +0000
    Re: how to extract page-URL using BeautifulSoup Joel Goldstick <joel.goldstick@gmail.com> - 2013-11-01 10:14 -0400

csiph-web