Path: csiph.com!news.swapon.de!fu-berlin.de!uni-berlin.de!not-for-mail From: Rob Hills Newsgroups: comp.lang.python Subject: Re: Find relative url in mixed text/html Date: Sun, 29 Nov 2015 01:44:58 +0800 Lines: 32 Message-ID: References: Reply-To: rhills@medimorphosis.com.au Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable X-Trace: news.uni-berlin.de QT3qbfh3xaFrXhueI5ZIGAQuVi0pAZoefNg+LOB4h/JA== Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.020 X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'subject:text': 0.04; 'context': 0.05; 'bits': 0.07; 'mentioned,': 0.07; 'purpose.': 0.07; 'skip:/ 10': 0.07; '(those': 0.09; 'assume': 0.11; 'url:)': 0.14; 'hurts': 0.16; 'received:74.55.86': 0.16; 'received:74.55.86.74': 0.16; 'received:io': 0.16; 'received:psf.io': 0.16; 'received:smtp.webfaction.com': 0.16; 'received:webfaction.com': 0.16; 'tweak': 0.16; 'wrote:': 0.16; 'url:au': 0.18; 'working.': 0.18; 'meant': 0.22; 'cheers,': 0.22; 'header:In-Reply-To:1': 0.24; "i've": 0.25; 'header:User-Agent:1': 0.26; 'example': 0.26; 'figure': 0.27; 'converting': 0.27; 'btw,': 0.29; "i'm": 0.30; 'subject:/': 0.30; 'code': 0.30; 'relative': 0.30; 'regardless': 0.31; "can't": 0.32; 'extract': 0.33; 'instances': 0.33; 'skip:/ 20': 0.33; "i'll": 0.33; 'so,': 0.35; 'ones': 0.35; 'could': 0.35; 'fail': 0.35; 'urls': 0.36; 'to:addr :python-list': 0.36; 'subject:: ': 0.37; 'really': 0.37; 'starting': 0.37; 'doing': 0.38; 'anything': 0.38; 'someone': 0.38; 'why': 0.39; 'sure': 0.39; 'enough': 0.39; 'received:192': 0.39; 'to:addr:python.org': 0.40; 'where': 0.40; 'some': 0.40; 'your': 0.60; 'skip:u 10': 0.61; 'australia': 0.61; 'back': 0.62; 'charset:windows-1252': 0.62; 'safe': 0.63; 'skip:w 30': 0.64; 'goal': 0.64; 'brain': 0.66; 'here': 0.66; 'header:Reply-To:1': 0.67; 'reply-to:no real name:2**0': 0.71; 'invitation': 0.80; 'url:asp': 0.80; 'appear,': 0.84; 'fortunately': 0.84; 'url:forums': 0.84; 'western': 0.89; 'hills': 0.93 X-Enigmail-Draft-Status: N1110 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 In-Reply-To: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.20+ Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Xref: csiph.com comp.lang.python:99672 Hi Grobu, On 28/11/15 15:07, Grobu wrote: > Is it safe to assume that all the relative (cross) links take one of > the following forms? : > > http://www.aeva.asn.au/forums/forum_posts.asp > www.aeva.asn.au/forums/forum_posts.asp > /forums/forum_posts.asp > /forum_posts.asp (are you really sure about this one?) > > If so, and if your goal boils down to converting all instances of old > style URLs to new style ones regardless of the context where they > appear, why would a regex fail to meet your needs? I'm actually not discounting anything and as I mentioned, I've already used some regex to extract the properly-formed URLs (those starting with http://). I was fortunately able to find some example regex that I could figure out enough to tweak for my purpose. Unfortunately, my small brain hurts whenever I try and understand what a piece of regex is doing and I don't like having bits in my code that hurt my brain.=20 BTW, that's not meant to be an invitation to someone to produce some regex for me, if I can't find any other way of doing it, I'll try and create my own regex and come back here if I can't get that working. Cheers, --=20 Rob Hills Waikiki, Western Australia