Getting a value that follows string.find()

Joel Goldstick joel.goldstick at gmail.com
Tue Aug 13 19:40:22 EDT 2013


On Tue, Aug 13, 2013 at 7:18 PM, Joel Goldstick
<joel.goldstick at gmail.com> wrote:
> On Tue, Aug 13, 2013 at 7:03 PM,  <englishkevin110 at gmail.com> wrote:
>> On Tuesday, August 13, 2013 5:58:07 PM UTC-5, Joel Goldstick wrote:
>>> lookup urlparse for you answer
>>>
>>>
>>>
>>> On Tue, Aug 13, 2013 at 6:51 PM,  <> wrote:
>>>
>>> > I know the title doesn't make much sense, but I didnt know how to explain my problem.
>>>
>>> >
>>>
>>> > Anywho, I've opened a page's source in URLLIB
>>>
>>> > starturlsource = starturlopen.read()
>>>
>>> > string.find(starturlsource, '<a href="/profile.php?id=')
>>>
>>> > And I used string.find to find a specific area in the page's source.
>>>
>>> > I want to store what comes after ?id= in a variable.
>>>
>>> > Can someone help me with this?
>>>
>>> > --
>>>
>>> > http://mail.python.org/mailman/listinfo/python-list
>>>
>>>
>>>
>>>
>>>
>>>
>>>
>>> --
>>>
>>> Joel Goldstick
>>>
>>> http://joelgoldstick.com
>>
>> I dont want to do any kind of HTML parsing.
>
> Aside from the fact that I really want a pony, and you seem to want
> your work done for you, look here:
>
> http://stackoverflow.com/questions/11600681/parse-query-part-from-url
>> --
>> http://mail.python.org/mailman/listinfo/python-list
>
>
>
> --
> Joel Goldstick
> http://joelgoldstick.com

I may have been too quick on my reading of you question.  You wanted
to get the value of the parameters, but also to find the url in the
page.  You want to do this without parsing, if I understand you.  The
good news is there is a module called Beautiful Soup that will do the
parsing for you.  The tutorial is way better than excellent, and you
will be up and running in less than a half hour from downloading the
module

http://www.crummy.com/software/BeautifulSoup/bs4/doc/

-- 
Joel Goldstick
http://joelgoldstick.com



More information about the Python-list mailing list